Fixed an issue related to handling an inactive syntax checker in the editor. 5_5_x

Thu, 18 Dec 2014 18:56:04 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 18 Dec 2014 18:56:04 +0100
branch
5_5_x
changeset 3973
f77cdeea80e3
parent 3969
1abc44583ef2
child 3976
1362182abdc7

Fixed an issue related to handling an inactive syntax checker in the editor.
(grafted from efc9c803ebdcbaa76ed6abc8b81d30dd2750b788)

Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Sat Dec 13 11:43:31 2014 +0100
+++ b/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Thu Dec 18 18:56:04 2014 +0100
@@ -65,8 +65,11 @@
         self.checkProgressLabel.setVisible(False)
         self.checkProgressLabel.setMaximumWidth(600)
         
-        self.syntaxCheckService = e5App().getObject('SyntaxCheckService')
-        self.syntaxCheckService.syntaxChecked.connect(self.__processResult)
+        try:
+            self.syntaxCheckService = e5App().getObject('SyntaxCheckService')
+            self.syntaxCheckService.syntaxChecked.connect(self.__processResult)
+        except KeyError:
+            self.syntaxCheckService = None
         self.filename = None
         
     def __resort(self):
@@ -140,37 +143,38 @@
         @param codestring string containing the code to be checked (string).
             If this is given, fn must be a single file name.
         """
-        if self.__project is None:
-            self.__project = e5App().getObject("Project")
-        
-        self.cancelled = False
-        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
-        self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
-        self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
-        self.checkProgress.setVisible(True)
-        QApplication.processEvents()
-        
-        if isinstance(fn, list):
-            self.files = fn
-        elif os.path.isdir(fn):
-            self.files = []
-            for ext in self.syntaxCheckService.getExtensions():
-                self.files.extend(
-                    Utilities.direntries(fn, True, '*{0}'.format(ext), 0))
-        else:
-            self.files = [fn]
-        
-        self.__clearErrors(self.files)
-        
-        if codestring or len(self.files) > 0:
-            self.checkProgress.setMaximum(max(1, len(self.files)))
-            self.checkProgress.setVisible(len(self.files) > 1)
-            self.checkProgressLabel.setVisible(len(self.files) > 1)
+        if self.syntaxCheckService is not None:
+            if self.__project is None:
+                self.__project = e5App().getObject("Project")
+            
+            self.cancelled = False
+            self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
+            self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
+            self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
+            self.checkProgress.setVisible(True)
             QApplication.processEvents()
+            
+            if isinstance(fn, list):
+                self.files = fn
+            elif os.path.isdir(fn):
+                self.files = []
+                for ext in self.syntaxCheckService.getExtensions():
+                    self.files.extend(
+                        Utilities.direntries(fn, True, '*{0}'.format(ext), 0))
+            else:
+                self.files = [fn]
+            
+            self.__clearErrors(self.files)
+            
+            if codestring or len(self.files) > 0:
+                self.checkProgress.setMaximum(max(1, len(self.files)))
+                self.checkProgress.setVisible(len(self.files) > 1)
+                self.checkProgressLabel.setVisible(len(self.files) > 1)
+                QApplication.processEvents()
 
-            # now go through all the files
-            self.progress = 0
-            self.check(codestring)
+                # now go through all the files
+                self.progress = 0
+                self.check(codestring)
     
     def check(self, codestring=''):
         """
@@ -179,7 +183,7 @@
         The results are reported to the __processResult slot.
         @keyparam codestring optional sourcestring (str)
         """
-        if not self.files:
+        if self.syntaxCheckService is None or not self.files:
             self.__finish()
             return
         
--- a/QScintilla/Editor.py	Sat Dec 13 11:43:31 2014 +0100
+++ b/QScintilla/Editor.py	Thu Dec 18 18:56:04 2014 +0100
@@ -315,9 +315,12 @@
         self.__setTextDisplay()
         
         # initialize the online syntax check timer
-        self.syntaxCheckService = e5App().getObject('SyntaxCheckService')
-        self.syntaxCheckService.syntaxChecked.connect(self.__processResult)
-        self.__initOnlineSyntaxCheck()
+        try:
+            self.syntaxCheckService = e5App().getObject('SyntaxCheckService')
+            self.syntaxCheckService.syntaxChecked.connect(self.__processResult)
+            self.__initOnlineSyntaxCheck()
+        except KeyError:
+            self.syntaxCheckService = None
         
         self.isResourcesFile = False
         if editor is None:
@@ -5072,7 +5075,8 @@
         """
         Public method to perform an automatic syntax check of the file.
         """
-        if self.filetype not in self.syntaxCheckService.getLanguages():
+        if self.syntaxCheckService is None or \
+                self.filetype not in self.syntaxCheckService.getLanguages():
             return
         
         if Preferences.getEditor("AutoCheckSyntax"):
@@ -6043,7 +6047,9 @@
         self.breakpointModel.rowsInserted.disconnect(
             self.__addBreakPoints)
         
-        self.syntaxCheckService.syntaxChecked.disconnect(self.__processResult)
+        if self.syntaxCheckService is not None:
+            self.syntaxCheckService.syntaxChecked.disconnect(
+                self.__processResult)
         
         if self.spell:
             self.spell.stopIncrementalCheck()

eric ide

mercurial