Changed some code to not call QCoreApplication.processEvents() too often. eric7

Sat, 29 Jan 2022 17:43:20 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 29 Jan 2022 17:43:20 +0100
branch
eric7
changeset 8934
d3798915e0d2
parent 8933
96301c65ed2e
child 8935
9ea72ee8130a

Changed some code to not call QCoreApplication.processEvents() too often.

eric7/DataViews/CodeMetricsDialog.py file | annotate | diff | comparison | revisions
eric7/EricNetwork/EricJsonServer.py file | annotate | diff | comparison | revisions
eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py file | annotate | diff | comparison | revisions
--- a/eric7/DataViews/CodeMetricsDialog.py	Thu Jan 27 17:54:11 2022 +0100
+++ b/eric7/DataViews/CodeMetricsDialog.py	Sat Jan 29 17:43:20 2022 +0100
@@ -7,9 +7,10 @@
 Module implementing a code metrics dialog.
 """
 
-import os
+import collections
 import fnmatch
-import collections
+import os
+import time
 
 from PyQt6.QtCore import pyqtSlot, Qt, QLocale
 from PyQt6.QtWidgets import (
@@ -175,6 +176,7 @@
             self.resultList.setSortingEnabled(False)
             
             # now go through all the files
+            now = time.monotonic()
             for progress, file in enumerate(files, start=1):
                 if self.cancelled:
                     return
@@ -192,7 +194,9 @@
                 self.resultList.expandItem(fitm)
                 
                 self.checkProgress.setValue(progress)
-                QApplication.processEvents()
+                if time.monotonic() - now > 0.01:
+                    QApplication.processEvents()
+                    now = time.monotonic()
         finally:
             # reenable updates of the list
             self.resultList.setSortingEnabled(True)
--- a/eric7/EricNetwork/EricJsonServer.py	Thu Jan 27 17:54:11 2022 +0100
+++ b/eric7/EricNetwork/EricJsonServer.py	Sat Jan 29 17:43:20 2022 +0100
@@ -12,7 +12,7 @@
 
 from PyQt6.QtCore import (
     pyqtSlot, QProcess, QProcessEnvironment, QCoreApplication, QEventLoop,
-    QTimer
+    QTimer, QThread
 )
 from PyQt6.QtNetwork import QTcpServer, QHostAddress
 
@@ -255,6 +255,7 @@
                     # connection of the client (= slow start).
                     QCoreApplication.processEvents(
                         QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents)
+                    QThread.msleep(100)
                     
                     # check if client exited prematurely
                     if proc.state() == QProcess.ProcessState.NotRunning:
--- a/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Thu Jan 27 17:54:11 2022 +0100
+++ b/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Sat Jan 29 17:43:20 2022 +0100
@@ -7,11 +7,12 @@
 Module implementing a dialog to show the results of the code style check.
 """
 
-import os
-import fnmatch
+import collections
 import copy
-import collections
+import fnmatch
 import json
+import os
+import time
 
 from PyQt6.QtCore import pyqtSlot, Qt, QTimer, QCoreApplication
 from PyQt6.QtGui import QIcon
@@ -194,6 +195,7 @@
         self.__batch = False
         self.__finished = True
         self.__errorItem = None
+        self.__timenow = time.monotonic()
         
         self.__fileOrFileList = ""
         self.__forProject = False
@@ -860,6 +862,8 @@
             # now go through all the files
             self.progress = 0
             self.files.sort()
+            self.__timenow = time.monotonic()
+            
             if len(self.files) == 1:
                 self.__batch = False
                 self.mainWidget.setCurrentWidget(self.resultsTab)
@@ -1003,7 +1007,9 @@
         # reset the progress bar to the checked files
         self.checkProgress.setValue(self.progress)
         self.checkProgressLabel.setPath(self.tr("Transferring data..."))
-        QApplication.processEvents()
+        if time.monotonic() - self.__timenow > 0.01:
+            QApplication.processEvents()
+            self.__timenow = time.monotonic()
         
         self.__finished = False
         self.styleCheckService.styleBatchCheck(argumentsList)
@@ -1124,7 +1130,9 @@
             row = self.progressList.row(fileItems[0])
             self.progressList.takeItem(row)
         
-        QApplication.processEvents()
+        if time.monotonic() - self.__timenow > 0.01:
+            QApplication.processEvents()
+            self.__timenow = time.monotonic()
     
     def __finish(self):
         """

eric ide

mercurial