diff -r 665f1084ebf9 -r 4d3e0ce54322 src/eric7/ViewManager/ViewManager.py --- a/src/eric7/ViewManager/ViewManager.py Wed Apr 10 10:45:31 2024 +0200 +++ b/src/eric7/ViewManager/ViewManager.py Wed Apr 10 16:45:06 2024 +0200 @@ -15,7 +15,6 @@ from PyQt6.Qsci import QsciScintilla from PyQt6.QtCore import ( QCoreApplication, - QFileSystemWatcher, QPoint, QSignalMapper, Qt, @@ -26,6 +25,7 @@ from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QToolBar, QWidget from eric7 import Preferences +from eric7.EricCore import EricFileSystemWatcher from eric7.EricGui import EricPixmapCache from eric7.EricGui.EricAction import EricAction, createActionGroup from eric7.EricWidgets import EricFileDialog, EricMessageBox @@ -145,8 +145,10 @@ self.__lastFocusWidget = None # initialize the file system watcher - self.__watcher = QFileSystemWatcher(self) - self.__watcher.fileChanged.connect(self.__watchedFileChanged) + watcher = EricFileSystemWatcher.instance() + watcher.fileModified.connect(self.__watchedFileChanged) + + self.__watchedFilePaths = [] def setReferences(self, ui, dbs): """ @@ -8072,8 +8074,14 @@ @param filePath path of the file to be added @type str """ - if filePath and FileSystemUtilities.isPlainFileName(filePath): - self.__watcher.addPath(filePath) + if ( + filePath + and FileSystemUtilities.isPlainFileName(filePath) + and filePath not in self.__watchedFilePaths + ): + watcher = EricFileSystemWatcher.instance() + watcher.addPath(filePath) + self.__watchedFilePaths.append(filePath) def removeWatchedFilePath(self, filePath): """ @@ -8082,10 +8090,15 @@ @param filePath path of the file to be removed @type str """ - if self.getOpenEditorCount( + if ( filePath - ) == 0 and FileSystemUtilities.isPlainFileName(filePath): - self.__watcher.removePath(filePath) + and self.getOpenEditorCount(filePath) == 0 + and FileSystemUtilities.isPlainFileName(filePath) + and filePath in self.__watchedFilePaths + ): + watcher = EricFileSystemWatcher.instance() + watcher.removePath(filePath) + self.__watchedFilePaths.remove(filePath) ################################################################## ## Below are protected utility methods