From 23ccad813d478c2fe507c7bc503911750ad99246 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 25 Jan 2010 12:55:38 +0000 Subject: [PATCH] Call Signalman::remove_all() when each of the Container subclasses commits suicide. SHould stop any stale signal handler connections existing --- terminatorlib/notebook.py | 1 + terminatorlib/paned.py | 1 + terminatorlib/signalman.py | 7 +++++++ terminatorlib/window.py | 1 + 4 files changed, 10 insertions(+) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 5ec3f9c0..1ac1084b 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -266,6 +266,7 @@ class Notebook(Container, gtk.Notebook): self.remove_page(0) parent = self.get_parent() parent.remove(self) + self.cnxids.remove_all() parent.add(child) del(self) diff --git a/terminatorlib/paned.py b/terminatorlib/paned.py index c7ce090c..da812a6f 100755 --- a/terminatorlib/paned.py +++ b/terminatorlib/paned.py @@ -126,6 +126,7 @@ class Paned(Container): parent = self.get_parent() parent.remove(self) + self.cnxids.remove_all() parent.add(sibling) del(self) else: diff --git a/terminatorlib/signalman.py b/terminatorlib/signalman.py index 810ca79e..1b5ac2c4 100755 --- a/terminatorlib/signalman.py +++ b/terminatorlib/signalman.py @@ -30,6 +30,7 @@ class Signalman(object): self.cnxids[widget][signal] = widget.connect(signal, handler, *args) dbg('connected %s::%s to %s' % (type(widget), signal, handler)) + return(self.cnxids[widget][signal]) def remove_signal(self, widget, signal): """Remove a signal handler""" @@ -55,3 +56,9 @@ class Signalman(object): for signal in signals: self.remove_signal(widget, signal) + def remove_all(self): + """Remove all signal handlers for all widgets""" + widgets = self.cnxids.keys() + for widget in widgets: + self.remove_widget(widget) + diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 5d58241f..ef711922 100755 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -182,6 +182,7 @@ class Window(Container, gtk.Window): def on_destroy_event(self, widget, data=None): """Handle window descruction""" + self.cnxids.remove_all() self.terminator.deregister_window(self) self.destroy() del(self)