Call Signalman::remove_all() when each of the Container subclasses commits suicide. SHould stop any stale signal handler connections existing

This commit is contained in:
Chris Jones 2010-01-25 12:55:38 +00:00
parent 8d8681e63f
commit 23ccad813d
4 changed files with 10 additions and 0 deletions

View File

@ -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)

View File

@ -126,6 +126,7 @@ class Paned(Container):
parent = self.get_parent()
parent.remove(self)
self.cnxids.remove_all()
parent.add(sibling)
del(self)
else:

View File

@ -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)

View File

@ -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)