src/eric7/ViewManager/ViewManager.py

branch
eric7
changeset 10685
a9134b4e8ed0
parent 10679
4d3e0ce54322
child 10688
0d9853ceb288
equal deleted inserted replaced
10684:58c7f23ae1cb 10685:a9134b4e8ed0
145 self.__lastFocusWidget = None 145 self.__lastFocusWidget = None
146 146
147 # initialize the file system watcher 147 # initialize the file system watcher
148 watcher = EricFileSystemWatcher.instance() 148 watcher = EricFileSystemWatcher.instance()
149 watcher.fileModified.connect(self.__watchedFileChanged) 149 watcher.fileModified.connect(self.__watchedFileChanged)
150 watcher.error.connect(self.__watcherError)
150 151
151 self.__watchedFilePaths = [] 152 self.__watchedFilePaths = []
152 153
153 def setReferences(self, ui, dbs): 154 def setReferences(self, ui, dbs):
154 """ 155 """
5710 """ 5711 """
5711 try: 5712 try:
5712 newWin, editor = self.getEditor( 5713 newWin, editor = self.getEditor(
5713 fn, filetype=filetype, addNext=addNext, indexes=indexes 5714 fn, filetype=filetype, addNext=addNext, indexes=indexes
5714 ) 5715 )
5715 except (OSError, UnicodeDecodeError): 5716 except (OSError, UnicodeDecodeError) as err:
5717 print(str(err))
5716 return None 5718 return None
5717 5719
5718 if newWin: 5720 if newWin:
5719 self._modificationStatusChanged(editor.isModified(), editor) 5721 self._modificationStatusChanged(editor.isModified(), editor)
5720 self._checkActions(editor) 5722 self._checkActions(editor)
6105 fn, 6107 fn,
6106 self, 6108 self,
6107 filetype=filetype, 6109 filetype=filetype,
6108 tv=ericApp().getObject("TaskViewer"), 6110 tv=ericApp().getObject("TaskViewer"),
6109 ) 6111 )
6112
6113 self.addWatchedFilePath(fn)
6114
6110 editor = assembly.getEditor() 6115 editor = assembly.getEditor()
6111 self.editors.append(editor) 6116 self.editors.append(editor)
6112 self.__connectEditor(editor) 6117 self.__connectEditor(editor)
6113 self.__editorOpened() 6118 self.__editorOpened()
6114 self.editorOpened.emit(fn) 6119 self.editorOpened.emit(fn)
6115 self.editorOpenedEd.emit(editor) 6120 self.editorOpenedEd.emit(editor)
6116 self.editorCountChanged.emit(len(self.editors)) 6121 self.editorCountChanged.emit(len(self.editors))
6117
6118 self.addWatchedFilePath(fn)
6119 6122
6120 newWin = True 6123 newWin = True
6121 6124
6122 if newWin: 6125 if newWin:
6123 self._addView(assembly, fn, addNext=addNext, indexes=indexes) 6126 self._addView(assembly, fn, addNext=addNext, indexes=indexes)
8065 8068
8066 # for all other views record the modification time only 8069 # for all other views record the modification time only
8067 for editor in editorList: 8070 for editor in editorList:
8068 editor.recordModificationTime() 8071 editor.recordModificationTime()
8069 8072
8073 @pyqtSlot(int, str)
8074 def __watcherError(self, errno, strerror):
8075 """
8076 Private slot to handle an error of the file system watcher.
8077
8078 @param errno numeric error code
8079 @type int
8080 @param strerror error message as provided by the operating system
8081 @type str
8082 """
8083 if errno == 24:
8084 EricMessageBox.critical(
8085 self,
8086 self.tr("File System Watcher Error"),
8087 self.tr(
8088 """<p>The operating system resources for file system watches"""
8089 """ are exhausted. This limit should be increased. On a Linux"""
8090 """ system you should """
8091 """<ul>"""
8092 """<li>sudo nano /etc/sysctl.conf</li>"""
8093 """<li>add to the bottom "fs.inotify.max_user_instances"""
8094 """ = 1024"</li>"""
8095 """<li>save and close the editor</li>"""
8096 """<li>sudo sysctl -p</li>"""
8097 """</ul></p><p>Error Message: {0}</p>"""
8098 ).format(strerror),
8099 )
8100 else:
8101 EricMessageBox.critical(
8102 self,
8103 self.tr("File System Watcher Error"),
8104 self.tr(
8105 "The file system watcher reported an error with code <b>{0}</b>."
8106 "</p><p>Error Message: {1}</p>"
8107 ).format(errno, strerror)
8108 )
8109
8070 def addWatchedFilePath(self, filePath): 8110 def addWatchedFilePath(self, filePath):
8071 """ 8111 """
8072 Public method to add a file to the list of monitored files. 8112 Public method to add a file to the list of monitored files.
8073 8113
8074 @param filePath path of the file to be added 8114 @param filePath path of the file to be added

eric ide

mercurial