[meld] Disconnect filter signals for removed tabs (closes bgo#681422)



commit 8b630abf4ebb4f965eab56c770b534b76aee8dec
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue Aug 28 07:26:56 2012 +1000

    Disconnect filter signals for removed tabs (closes bgo#681422)
    
    When removing a tab, we weren't disconnecting the various 'filter
    changed' signals on the app. With these tabs not properly unrefed, the
    signals would continue to fire after the widget tree had already been
    destroyed, causing tracebacks and badness.
    
    This patch adds cleanup of these app-level signals to the delete events
    of individual DirDiff and FileDiff tabs.

 meld/dirdiff.py  |   15 ++++++++++++---
 meld/filediff.py |    6 +++++-
 2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 9d4c612..04e87b4 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -248,11 +248,14 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
         self.actiongroup.add_actions(actions)
         self.actiongroup.add_toggle_actions(toggleactions)
         self.name_filters = []
-        self.create_name_filters()
-        app.connect("file-filters-changed", self.on_file_filters_changed)
         self.text_filters = []
+        self.create_name_filters()
         self.create_text_filters()
-        app.connect("text-filters-changed", self.on_text_filters_changed)
+        self.app_handlers = [app.connect("file-filters-changed",
+                                         self.on_file_filters_changed),
+                             app.connect("text-filters-changed",
+                                         self.on_text_filters_changed)]
+
         for button in ("DirCompare", "DirCopyLeft", "DirCopyRight",
                        "DirDelete", "ShowSame",
                        "ShowNew", "ShowModified", "CustomFilterMenu"):
@@ -1183,3 +1186,9 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
 
     def on_reload_activate(self, *extra):
         self.on_fileentry_activate(None)
+
+    def on_delete_event(self, appquit=0):
+        for h in self.app_handlers:
+            app.disconnect(h)
+
+        return gtk.RESPONSE_OK
diff --git a/meld/filediff.py b/meld/filediff.py
index 09bf8c3..40f724d 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -162,7 +162,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         self.undosequence = undo.UndoSequence()
         self.text_filters = []
         self.create_text_filters()
-        app.connect("text-filters-changed", self.on_text_filters_changed)
+        self.app_handlers = [app.connect("text-filters-changed",
+                             self.on_text_filters_changed)]
         self.buffer_filtered = [meldbuffer.BufferLines(b, self._filter_text)
                                 for b in self.textbuffer]
         for (i, w) in enumerate(self.scrolledwindow):
@@ -740,6 +741,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
                             return gtk.RESPONSE_CANCEL
             elif response == gtk.RESPONSE_DELETE_EVENT:
                 response = gtk.RESPONSE_CANCEL
+        if response == gtk.RESPONSE_OK:
+            for h in self.app_handlers:
+                app.disconnect(h)
         return response
 
         #



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]