Don't process events after each file to prevent a slow search. eric7

Wed, 26 Jan 2022 22:17:41 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 26 Jan 2022 22:17:41 +0100
branch
eric7
changeset 8932
a21e80dde10e
parent 8930
5e3bd6f49a84
child 8933
96301c65ed2e

Don't process events after each file to prevent a slow search.

eric7/UI/FindFileWidget.py file | annotate | diff | comparison | revisions
--- a/eric7/UI/FindFileWidget.py	Sat Jan 22 17:03:25 2022 +0100
+++ b/eric7/UI/FindFileWidget.py	Wed Jan 26 22:17:41 2022 +0100
@@ -9,6 +9,7 @@
 
 import os
 import re
+import time
 
 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QPoint, QUrl
 from PyQt6.QtGui import QCursor, QDesktopServices, QImageReader
@@ -615,6 +616,7 @@
                 self.findProgress.setValue(progress)
                 continue
             
+            now = time.monotonic()
             # now perform the search and display the lines found
             for count, line in enumerate(lines, start=1):
                 if self.__cancelSearch:
@@ -641,7 +643,9 @@
                     self.__createItem(file, count, line, start, end,
                                       rline, hashStr)
                 
-                QApplication.processEvents()
+                if time.monotonic() - now > 0.01:
+                    QApplication.processEvents()
+                    now = time.monotonic()
             
             if found:
                 fileOccurrences += 1

eric ide

mercurial