4352: more memory leak problems
Fix some memory leak problems in guioptions svn: r16521
This commit is contained in:
parent
070e9ef707
commit
2d052d69cf
@ -173,7 +173,7 @@ class GuiStringOption(gtk.Entry):
|
||||
self.connect('changed', self.__text_changed)
|
||||
self.set_tooltip_text(self.__option.get_help())
|
||||
|
||||
self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.conkey = self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.__update_avail()
|
||||
|
||||
def __text_changed(self, obj): # IGNORE:W0613 - obj is unused
|
||||
@ -189,6 +189,13 @@ class GuiStringOption(gtk.Entry):
|
||||
avail = self.__option.get_available()
|
||||
self.set_sensitive(avail)
|
||||
|
||||
def clean_up(self):
|
||||
"""
|
||||
remove stuff that blocks garbage collection
|
||||
"""
|
||||
self.__option.disconnect(self.conkey)
|
||||
self.__option = None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GuiColorOption class
|
||||
@ -248,7 +255,7 @@ class GuiNumberOption(gtk.SpinButton):
|
||||
self.connect('value_changed', self.__value_changed)
|
||||
self.set_tooltip_text(self.__option.get_help())
|
||||
|
||||
self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.conkey = self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.__update_avail()
|
||||
|
||||
def __value_changed(self, obj): # IGNORE:W0613 - obj is unused
|
||||
@ -265,6 +272,13 @@ class GuiNumberOption(gtk.SpinButton):
|
||||
avail = self.__option.get_available()
|
||||
self.set_sensitive(avail)
|
||||
|
||||
def clean_up(self):
|
||||
"""
|
||||
remove stuff that blocks garbage collection
|
||||
"""
|
||||
self.__option.disconnect(self.conkey)
|
||||
self.__option = None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GuiTextOption class
|
||||
@ -293,7 +307,7 @@ class GuiTextOption(gtk.ScrolledWindow):
|
||||
gtext.set_tooltip_text(self.__option.get_help())
|
||||
|
||||
self.__buff = gtext.get_buffer()
|
||||
self.__buff.connect('changed', self.__value_changed)
|
||||
self.bufcon = self.__buff.connect('changed', self.__value_changed)
|
||||
|
||||
def __value_changed(self, obj): # IGNORE:W0613 - obj is unused
|
||||
"""
|
||||
@ -304,6 +318,14 @@ class GuiTextOption(gtk.ScrolledWindow):
|
||||
False) )
|
||||
self.__option.set_value( text_val.split('\n') )
|
||||
|
||||
def clean_up(self):
|
||||
"""
|
||||
remove stuff that blocks garbage collection
|
||||
"""
|
||||
self.__option = None
|
||||
self.__buff.disconnect(self.bufcon)
|
||||
self.__buff = None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GuiBooleanOption class
|
||||
@ -320,7 +342,7 @@ class GuiBooleanOption(gtk.CheckButton):
|
||||
self.connect('toggled', self.__value_changed)
|
||||
self.set_tooltip_text(self.__option.get_help())
|
||||
|
||||
self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.conkey = self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.__update_avail()
|
||||
|
||||
def __value_changed(self, obj): # IGNORE:W0613 - obj is unused
|
||||
@ -336,6 +358,13 @@ class GuiBooleanOption(gtk.CheckButton):
|
||||
avail = self.__option.get_available()
|
||||
self.set_sensitive(avail)
|
||||
|
||||
def clean_up(self):
|
||||
"""
|
||||
remove stuff that blocks garbage collection
|
||||
"""
|
||||
self.__option.disconnect(self.conkey)
|
||||
self.__option = None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GuiEnumeratedListOption class
|
||||
@ -359,8 +388,8 @@ class GuiEnumeratedListOption(gtk.HBox):
|
||||
self.set_tooltip_text(self.__option.get_help())
|
||||
|
||||
self.__combo.connect('changed', self.__value_changed)
|
||||
self.__option.connect('options-changed', self.__update_options)
|
||||
self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.conkey1 = self.__option.connect('options-changed', self.__update_options)
|
||||
self.conkey2 = self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.__update_avail()
|
||||
|
||||
def __value_changed(self, obj): # IGNORE:W0613 - obj is unused
|
||||
@ -400,6 +429,14 @@ class GuiEnumeratedListOption(gtk.HBox):
|
||||
avail = self.__option.get_available()
|
||||
self.set_sensitive(avail)
|
||||
|
||||
def clean_up(self):
|
||||
"""
|
||||
remove stuff that blocks garbage collection
|
||||
"""
|
||||
self.__option.disconnect(self.conkey1)
|
||||
self.__option.disconnect(self.conkey2)
|
||||
self.__option = None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GuiPersonOption class
|
||||
@ -443,7 +480,7 @@ class GuiPersonOption(gtk.HBox):
|
||||
pevt.set_tooltip_text(self.__option.get_help())
|
||||
person_button.set_tooltip_text(_('Select a different person'))
|
||||
|
||||
self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.conkey = self.__option.connect('avail-changed', self.__update_avail)
|
||||
self.__update_avail()
|
||||
|
||||
def __get_person_clicked(self, obj): # IGNORE:W0613 - obj is unused
|
||||
@ -493,6 +530,13 @@ class GuiPersonOption(gtk.HBox):
|
||||
avail = self.__option.get_available()
|
||||
self.set_sensitive(avail)
|
||||
|
||||
def clean_up(self):
|
||||
"""
|
||||
remove stuff that blocks garbage collection
|
||||
"""
|
||||
self.__option.disconnect(self.conkey)
|
||||
self.__option = None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GuiFamilyOption class
|
||||
|
@ -98,6 +98,29 @@ class ReportDialog(ManagedWindow.ManagedWindow):
|
||||
self.init_options(option_class)
|
||||
self.init_interface()
|
||||
|
||||
def close(self, *obj):
|
||||
"""
|
||||
Close itself.
|
||||
cleanup things that can prevent garbage collection
|
||||
"""
|
||||
totwidg = range(len(self.widgets))
|
||||
totwidg.reverse()
|
||||
for ind in totwidg:
|
||||
if hasattr(self.widgets[ind][1], 'clean_up'):
|
||||
self.widgets[ind][1].clean_up()
|
||||
del self.widgets[ind]
|
||||
delattr(self, 'widgets')
|
||||
for name, fram in self.frames.iteritems():
|
||||
totwidg = range(len(fram))
|
||||
totwidg.reverse()
|
||||
for ind in totwidg:
|
||||
if hasattr(fram[ind][1], 'clean_up'):
|
||||
fram[ind][1].clean_up()
|
||||
del fram[ind]
|
||||
self.frames.clear()
|
||||
self.frames = None
|
||||
ManagedWindow.ManagedWindow.close(self, *obj)
|
||||
|
||||
def init_options(self, option_class):
|
||||
try:
|
||||
if (issubclass(option_class, object) or # New-style class
|
||||
@ -657,3 +680,11 @@ def report(dbstate, uistate, person, report_class, options_class,
|
||||
#just stop, in ManagedWindow, delete-event is already coupled to
|
||||
#correct action.
|
||||
break
|
||||
#do needed cleanup
|
||||
dialog.db = None
|
||||
dialog.options = None
|
||||
if hasattr(dialog, 'window'):
|
||||
delattr(dialog, 'window')
|
||||
if hasattr(dialog, 'notebook'):
|
||||
delattr(dialog, 'notebook')
|
||||
del dialog
|
||||
|
Loading…
Reference in New Issue
Block a user