Fixed an issue in the editor caused by double connecting to a signal.

Sun, 01 Apr 2012 14:31:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 01 Apr 2012 14:31:29 +0200
changeset 1754
4e2f87d03546
parent 1749
cfddfc179a2c
child 1755
976457c61226

Fixed an issue in the editor caused by double connecting to a signal.

QScintilla/Editor.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
ViewManager/ViewManager.py file | annotate | diff | comparison | revisions
--- a/QScintilla/Editor.py	Sat Mar 31 19:15:17 2012 +0200
+++ b/QScintilla/Editor.py	Sun Apr 01 14:31:29 2012 +0200
@@ -411,6 +411,11 @@
         # create the online syntax check timer
         self.__initOnlineSyntaxCheck()
         
+        if self.fileName and \
+           self.project.isOpen() and \
+           self.project.isProjectSource(self.fileName):
+            self.project.projectPropertiesChanged.connect(self.__projectPropertiesChanged)
+        
         self.grabGesture(Qt.PinchGesture)
     
     def __registerImages(self):
@@ -5288,8 +5293,12 @@
         
         if self.spell:
             self.spell.stopIncrementalCheck()
+        
+        try:
             self.project.projectPropertiesChanged.disconnect(
                 self.__projectPropertiesChanged)
+        except TypeError:
+            pass
         
         if self.fileName:
             self.taskViewer.clearFileTasks(self.fileName, True)
@@ -5885,7 +5894,27 @@
             pwl, pel = self.project.getProjectDictionaries()
             self.__setSpellingLanguage(self.project.getProjectSpellLanguage(),
                                        pwl=pwl, pel=pel)
+        
+        self.project.projectPropertiesChanged.connect(self.__projectPropertiesChanged)
+    
+    def projectOpened(self):
+        """
+        Public slot to handle the opening of a project.
+        """
+        if self.fileName and \
+           self.project.isProjectSource(self.fileName):
             self.project.projectPropertiesChanged.connect(self.__projectPropertiesChanged)
+            self.setSpellingForProject()
+    
+    def projectClosed(self):
+        """
+        Public slot to handle the closing of a project.
+        """
+        try:
+            self.project.projectPropertiesChanged.disconnect(
+                self.__projectPropertiesChanged)
+        except TypeError:
+            pass
     
     #######################################################################
     ## Spellchecking related methods
@@ -5913,7 +5942,6 @@
                 self.spell = SpellChecker(self, self.spellingIndicator,
                                           checkRegion=self.isSpellCheckRegion)
             self.setSpellingForProject()
-            self.project.projectPropertiesChanged.connect(self.__projectPropertiesChanged)
             self.spell.setMinimumWordSize(
                 Preferences.getEditor("SpellCheckingMinWordSize"))
             
--- a/UI/UserInterface.py	Sat Mar 31 19:15:17 2012 +0200
+++ b/UI/UserInterface.py	Sun Apr 01 14:31:29 2012 +0200
@@ -366,6 +366,7 @@
         
         self.project.sourceFile.connect(self.viewmanager.openSourceFile)
         self.project.projectOpened.connect(self.viewmanager.projectOpened)
+        self.project.projectClosed.connect(self.viewmanager.projectClosed)
         self.project.projectFileRenamed.connect(self.viewmanager.projectFileRenamed)
         self.project.lexerAssociationsChanged.connect(
             self.viewmanager.projectLexerAssociationsChanged)
--- a/ViewManager/ViewManager.py	Sat Mar 31 19:15:17 2012 +0200
+++ b/ViewManager/ViewManager.py	Sun Apr 01 14:31:29 2012 +0200
@@ -4191,8 +4191,15 @@
         Public slot to handle the projectOpened signal.
         """
         for editor in self.editors:
-            editor.setSpellingForProject()
-        
+            editor.projectOpened()
+    
+    def projectClosed(self):
+        """
+        Public slot to handle the projectClosed signal.
+        """
+        for editor in self.editors:
+            editor.projectClosed()
+    
     def projectFileRenamed(self, oldfn, newfn):
         """
         Public slot to handle the projectFileRenamed signal.

eric ide

mercurial