4333: memory leak in 3.2
svn: r16105
This commit is contained in:
parent
2bbd218269
commit
443fae3890
@ -57,7 +57,15 @@ class SearchBar(object):
|
||||
self.filter_model = gtk.ListStore(gobject.TYPE_STRING,
|
||||
gobject.TYPE_INT,
|
||||
gobject.TYPE_BOOLEAN)
|
||||
|
||||
|
||||
def destroy(self):
|
||||
"""Unset all things that can block garbage collection.
|
||||
"""
|
||||
self.on_apply_callback = None
|
||||
self.apply_done_callback = None
|
||||
self.dbstate = None
|
||||
self.uistate = None
|
||||
|
||||
def build( self):
|
||||
self.filterbar.set_spacing(4)
|
||||
self.filter_list.connect('changed', self.filter_changed)
|
||||
|
@ -69,6 +69,7 @@ class EmbeddedList(ButtonTab):
|
||||
move_buttons, jump_button)
|
||||
|
||||
self.changed = False
|
||||
self.model = None
|
||||
self.build_model = build_model
|
||||
|
||||
# handle the selection
|
||||
@ -467,6 +468,9 @@ class EmbeddedList(ButtonTab):
|
||||
selectedpath = None
|
||||
if node:
|
||||
selectedpath = model.get_path(node)
|
||||
if self.model and hasattr(self.model, 'destroy'):
|
||||
self.tree.set_model(None)
|
||||
self.model.destroy()
|
||||
try:
|
||||
self.model = self.construct_model()
|
||||
except AttributeError, msg:
|
||||
|
@ -134,15 +134,15 @@ class EditAddress(EditSecondary):
|
||||
|
||||
notebook = gtk.Notebook()
|
||||
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook,
|
||||
SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj))
|
||||
self.srcref_list = SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj)
|
||||
self._add_tab(notebook, self.srcref_list)
|
||||
self.track_ref_for_deletion("srcref_list")
|
||||
|
||||
self.note_tab = self._add_tab(
|
||||
notebook,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_note_list(),
|
||||
notetype=NoteType.ADDRESS))
|
||||
notetype=NoteType.ADDRESS)
|
||||
self._add_tab(notebook, self.note_tab)
|
||||
self.track_ref_for_deletion("note_tab")
|
||||
|
||||
self._setup_notebook_tabs( notebook)
|
||||
notebook.show_all()
|
||||
|
@ -107,15 +107,15 @@ class EditAttribute(EditSecondary):
|
||||
|
||||
def _create_tabbed_pages(self):
|
||||
notebook = gtk.Notebook()
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook,
|
||||
SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj))
|
||||
self.srcref_list = SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj)
|
||||
self._add_tab(notebook, self.srcref_list)
|
||||
self.track_ref_for_deletion("srcref_list")
|
||||
|
||||
self.note_tab = self._add_tab(
|
||||
notebook,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_note_list(),
|
||||
notetype = NoteType.ATTRIBUTE))
|
||||
notetype = NoteType.ATTRIBUTE)
|
||||
self._add_tab(notebook, self.note_tab)
|
||||
self.track_ref_for_deletion("note_tab")
|
||||
|
||||
self._setup_notebook_tabs( notebook)
|
||||
notebook.show_all()
|
||||
|
@ -144,15 +144,15 @@ class EditChildRef(EditSecondary):
|
||||
"""
|
||||
notebook = gtk.Notebook()
|
||||
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook,
|
||||
SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj))
|
||||
self.srcref_list = SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj)
|
||||
self._add_tab(notebook, self.srcref_list)
|
||||
self.track_ref_for_deletion("srcref_list")
|
||||
|
||||
self.note_tab = self._add_tab(
|
||||
notebook,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_note_list(),
|
||||
notetype=NoteType.CHILDREF))
|
||||
notetype=NoteType.CHILDREF)
|
||||
self._add_tab(notebook, self.note_tab)
|
||||
self.track_ref_for_deletion("note_tab")
|
||||
|
||||
self._setup_notebook_tabs( notebook)
|
||||
notebook.show_all()
|
||||
|
@ -198,6 +198,7 @@ class EditLdsOrd(EditSecondary):
|
||||
if item[0] in self._get_types()],
|
||||
self.db.readonly,
|
||||
changed=self.ord_type_changed)
|
||||
self.track_ref_for_deletion('type_menu')
|
||||
|
||||
self.temple_menu = MonitoredStrMenu(
|
||||
self.top.get_object('temple'),
|
||||
@ -205,6 +206,7 @@ class EditLdsOrd(EditSecondary):
|
||||
self.obj.get_temple,
|
||||
LdsUtils.TEMPLES.name_code_data(),
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion('temple_menu')
|
||||
|
||||
self.status_menu = MonitoredMenu(
|
||||
self.top.get_object('status'),
|
||||
@ -213,6 +215,7 @@ class EditLdsOrd(EditSecondary):
|
||||
[(item[1],item[0]) for item in gen.lib.LdsOrd._STATUS_MAP
|
||||
if item[0] in _DATA_MAP[self.obj.get_type()] ],
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion('status_menu')
|
||||
|
||||
self.ord_type_changed()
|
||||
self.update_parent_label()
|
||||
@ -236,15 +239,16 @@ class EditLdsOrd(EditSecondary):
|
||||
|
||||
def _create_tabbed_pages(self):
|
||||
notebook = gtk.Notebook()
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook,
|
||||
SourceEmbedList(self.dbstate,self.uistate, self.track,self.obj))
|
||||
self.srcref_list = SourceEmbedList(self.dbstate, self.uistate,
|
||||
self.track, self.obj)
|
||||
self._add_tab(notebook, self.srcref_list)
|
||||
self.track_ref_for_deletion("srcref_list")
|
||||
|
||||
self.note_tab = self._add_tab(
|
||||
notebook,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_note_list(),
|
||||
notetype=gen.lib.NoteType.LDS))
|
||||
notetype=gen.lib.NoteType.LDS)
|
||||
self._add_tab(notebook, self.note_tab)
|
||||
self.track_ref_for_deletion("note_tab")
|
||||
|
||||
self._setup_notebook_tabs( notebook)
|
||||
notebook.show_all()
|
||||
@ -304,6 +308,7 @@ class EditLdsOrd(EditSecondary):
|
||||
"""
|
||||
if self.callback:
|
||||
self.callback(self.obj)
|
||||
self.callback = None
|
||||
self.close()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -378,6 +383,7 @@ class EditFamilyLdsOrd(EditSecondary):
|
||||
[(item[1],item[0]) for item in gen.lib.LdsOrd._TYPE_MAP
|
||||
if item[0] in self._get_types()],
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion('type_menu')
|
||||
|
||||
self.temple_menu = MonitoredStrMenu(
|
||||
self.top.get_object('temple'),
|
||||
@ -385,6 +391,7 @@ class EditFamilyLdsOrd(EditSecondary):
|
||||
self.obj.get_temple,
|
||||
LdsUtils.TEMPLES.name_code_data(),
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion('temple_menu')
|
||||
|
||||
self.status_menu = MonitoredMenu(
|
||||
self.top.get_object('status'),
|
||||
@ -393,18 +400,19 @@ class EditFamilyLdsOrd(EditSecondary):
|
||||
[(item[1],item[0]) for item in gen.lib.LdsOrd._STATUS_MAP
|
||||
if item[0] in _DATA_MAP[self.obj.get_type()]],
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion('status_menu')
|
||||
|
||||
def _create_tabbed_pages(self):
|
||||
notebook = gtk.Notebook()
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook,
|
||||
SourceEmbedList(self.dbstate,self.uistate, self.track,self.obj))
|
||||
self.srcref_list = SourceEmbedList(self.dbstate,self.uistate, self.track,self.obj)
|
||||
self._add_tab(notebook, self.srcref_list)
|
||||
self.track_ref_for_deletion("srcref_list")
|
||||
|
||||
self.note_tab = self._add_tab(
|
||||
notebook,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_note_list(),
|
||||
notetype=gen.lib.NoteType.LDS))
|
||||
notetype=gen.lib.NoteType.LDS)
|
||||
self._add_tab(notebook, self.note_tab)
|
||||
self.track_ref_for_deletion("note_tab")
|
||||
|
||||
notebook.show_all()
|
||||
self.top.get_object('vbox').pack_start(notebook,True)
|
||||
|
@ -82,21 +82,27 @@ class EditMediaRef(EditReference):
|
||||
self.top.get_object("label428").set_text(_("Y coordinate|Y"))
|
||||
|
||||
tblref = self.top.get_object('table50')
|
||||
notebook = self.top.get_object('notebook_ref')
|
||||
self.notebook_ref = self.top.get_object('notebook_ref')
|
||||
self.track_ref_for_deletion("notebook_ref")
|
||||
#recreate start page as GrampsTab
|
||||
notebook.remove_page(0)
|
||||
self.notebook_ref.remove_page(0)
|
||||
self.reftab = RefTab(self.dbstate, self.uistate, self.track,
|
||||
_('General'), tblref)
|
||||
self.track_ref_for_deletion("reftab")
|
||||
tblref = self.top.get_object('table2')
|
||||
notebook = self.top.get_object('notebook_shared')
|
||||
self.notebook_shared = self.top.get_object('notebook_shared')
|
||||
#recreate start page as GrampsTab
|
||||
notebook.remove_page(0)
|
||||
self.notebook_shared.remove_page(0)
|
||||
self.track_ref_for_deletion("notebook_shared")
|
||||
self.primtab = RefTab(self.dbstate, self.uistate, self.track,
|
||||
_('_General'), tblref)
|
||||
self.track_ref_for_deletion("primtab")
|
||||
|
||||
def setup_filepath(self):
|
||||
self.select = self.top.get_object('file_select')
|
||||
self.track_ref_for_deletion("select")
|
||||
self.file_path = self.top.get_object("path")
|
||||
self.track_ref_for_deletion("file_path")
|
||||
|
||||
self.file_path.set_text(self.source.get_path())
|
||||
self.select.connect('clicked', self.select_file)
|
||||
@ -154,6 +160,7 @@ class EditMediaRef(EditReference):
|
||||
|
||||
self.pixmap = self.top.get_object("pixmap")
|
||||
self.mimetext = self.top.get_object("type")
|
||||
self.track_ref_for_deletion("mimetext")
|
||||
|
||||
coord = self.source_ref.get_rectangle()
|
||||
#upgrade path: set invalid (from eg old db) to none
|
||||
@ -167,6 +174,7 @@ class EditMediaRef(EditReference):
|
||||
|
||||
self.rectangle = coord
|
||||
self.subpixmap = self.top.get_object("subpixmap")
|
||||
self.track_ref_for_deletion("subpixmap")
|
||||
|
||||
self.setup_filepath()
|
||||
self.determine_mime()
|
||||
@ -190,24 +198,28 @@ class EditMediaRef(EditReference):
|
||||
self.set_corner1_x,
|
||||
self.get_corner1_x,
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion("corner1_x_spinbutton")
|
||||
|
||||
self.corner1_y_spinbutton = MonitoredSpinButton(
|
||||
self.top.get_object("corner1_y"),
|
||||
self.set_corner1_y,
|
||||
self.get_corner1_y,
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion("corner1_y_spinbutton")
|
||||
|
||||
self.corner2_x_spinbutton = MonitoredSpinButton(
|
||||
self.top.get_object("corner2_x"),
|
||||
self.set_corner2_x,
|
||||
self.get_corner2_x,
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion("corner2_x_spinbutton")
|
||||
|
||||
self.corner2_y_spinbutton = MonitoredSpinButton(
|
||||
self.top.get_object("corner2_y"),
|
||||
self.set_corner2_y,
|
||||
self.get_corner2_y,
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion("corner2_y_spinbutton")
|
||||
|
||||
self.descr_window = MonitoredEntry(
|
||||
self.top.get_object("description"),
|
||||
@ -530,44 +542,44 @@ class EditMediaRef(EditReference):
|
||||
self._add_tab(notebook_src, self.primtab)
|
||||
self._add_tab(notebook_ref, self.reftab)
|
||||
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook_ref,
|
||||
SourceEmbedList(self.dbstate,self.uistate,self.track,
|
||||
self.source_ref))
|
||||
self.srcref_list = SourceEmbedList(self.dbstate,self.uistate,self.track,
|
||||
self.source_ref)
|
||||
self._add_tab(notebook_ref, self.srcref_list)
|
||||
self.track_ref_for_deletion("srcref_list")
|
||||
|
||||
self.attr_list = self._add_tab(
|
||||
notebook_ref,
|
||||
AttrEmbedList(self.dbstate,self.uistate,self.track,
|
||||
self.source_ref.get_attribute_list()))
|
||||
self.attr_list = AttrEmbedList(self.dbstate,self.uistate,self.track,
|
||||
self.source_ref.get_attribute_list())
|
||||
self._add_tab(notebook_ref, self.attr_list)
|
||||
self.track_ref_for_deletion("attr_list")
|
||||
|
||||
self.backref_list = self._add_tab(
|
||||
notebook_src,
|
||||
MediaBackRefList(self.dbstate,self.uistate,self.track,
|
||||
self.backref_list = MediaBackRefList(self.dbstate,self.uistate,self.track,
|
||||
self.db.find_backlink_handles(self.source.handle),
|
||||
self.enable_warnbox
|
||||
))
|
||||
)
|
||||
self._add_tab(notebook_src, self.backref_list)
|
||||
self.track_ref_for_deletion("backref_list")
|
||||
|
||||
self.note_ref_tab = self._add_tab(
|
||||
notebook_ref,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.source_ref.get_note_list(),
|
||||
notetype=NoteType.MEDIAREF))
|
||||
self.note_ref_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.source_ref.get_note_list(),
|
||||
notetype=NoteType.MEDIAREF)
|
||||
self._add_tab(notebook_ref, self.note_ref_tab)
|
||||
self.track_ref_for_deletion("note_ref_tab")
|
||||
|
||||
self.src_srcref_list = self._add_tab(
|
||||
notebook_src,
|
||||
SourceEmbedList(self.dbstate,self.uistate,self.track,
|
||||
self.source))
|
||||
self.src_srcref_list = SourceEmbedList(self.dbstate,self.uistate,
|
||||
self.track, self.source)
|
||||
self._add_tab(notebook_src, self.src_srcref_list)
|
||||
self.track_ref_for_deletion("src_srcref_list")
|
||||
|
||||
self.src_attr_list = self._add_tab(
|
||||
notebook_src,
|
||||
AttrEmbedList(self.dbstate,self.uistate,self.track,
|
||||
self.source.get_attribute_list()))
|
||||
self.src_attr_list = AttrEmbedList(self.dbstate,self.uistate,self.track,
|
||||
self.source.get_attribute_list())
|
||||
self._add_tab(notebook_src, self.src_attr_list)
|
||||
self.track_ref_for_deletion("src_attr_list")
|
||||
|
||||
self.src_note_ref_tab = self._add_tab(
|
||||
notebook_src,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.source.get_note_list(),
|
||||
notetype=NoteType.MEDIA))
|
||||
self.src_note_ref_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.source.get_note_list(),
|
||||
notetype=NoteType.MEDIA)
|
||||
self._add_tab(notebook_src, self.src_note_ref_tab)
|
||||
self.track_ref_for_deletion("src_note_ref_tab")
|
||||
|
||||
self._setup_notebook_tabs(notebook_src)
|
||||
self._setup_notebook_tabs(notebook_ref)
|
||||
@ -606,5 +618,5 @@ class EditMediaRef(EditReference):
|
||||
#call callback if given
|
||||
if self.update:
|
||||
self.update(self.source_ref,self.source)
|
||||
|
||||
self.update = None
|
||||
self.close()
|
||||
|
@ -141,19 +141,20 @@ class EditPersonRef(EditSecondary):
|
||||
|
||||
notebook = gtk.Notebook()
|
||||
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook,
|
||||
SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj))
|
||||
|
||||
self.note_tab = self._add_tab(
|
||||
notebook,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_note_list(),
|
||||
notetype=NoteType.ASSOCIATION))
|
||||
self.srcref_list = SourceEmbedList(self.dbstate, self.uistate,
|
||||
self.track, self.obj)
|
||||
self._add_tab(notebook, self.srcref_list)
|
||||
self.track_ref_for_deletion("srcref_list")
|
||||
|
||||
self._setup_notebook_tabs( notebook)
|
||||
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_note_list(),
|
||||
notetype=NoteType.ASSOCIATION)
|
||||
self._add_tab(notebook, self.note_tab)
|
||||
self.track_ref_for_deletion("note_tab")
|
||||
|
||||
self._setup_notebook_tabs(notebook)
|
||||
notebook.show_all()
|
||||
self.top.get_object('vbox').pack_start(notebook,True)
|
||||
self.top.get_object('vbox').pack_start(notebook, True)
|
||||
|
||||
def build_menu_names(self, obj):
|
||||
return (_('Person Reference'),_('Person Reference Editor'))
|
||||
@ -167,6 +168,7 @@ class EditPersonRef(EditSecondary):
|
||||
if self.obj.ref:
|
||||
if self.callback:
|
||||
self.callback(self.obj)
|
||||
self.callback = None
|
||||
self.close()
|
||||
else:
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
@ -186,7 +186,6 @@ class EditReference(ManagedWindow.ManagedWindow, DbGUIElement):
|
||||
button.connect('clicked',self.close_and_cancel)
|
||||
|
||||
def close_and_cancel(self, obj):
|
||||
self._cleanup_on_exit()
|
||||
self.close(obj)
|
||||
|
||||
def check_for_close(self, handles):
|
||||
@ -205,11 +204,27 @@ class EditReference(ManagedWindow.ManagedWindow, DbGUIElement):
|
||||
button.set_sensitive(True)
|
||||
|
||||
def _cleanup_on_exit(self):
|
||||
pass
|
||||
"""Unset all things that can block garbage collection.
|
||||
Finalize rest
|
||||
"""
|
||||
for tab in self.__tabs:
|
||||
if hasattr(tab, '_cleanup_on_exit'):
|
||||
tab._cleanup_on_exit()
|
||||
self.__tabs = None
|
||||
self.dbstate = None
|
||||
self.uistate = None
|
||||
self.source_ref = None
|
||||
self.source = None
|
||||
self.update = None
|
||||
self.warn_box = None
|
||||
self.db = None
|
||||
self.callman.database = None
|
||||
self.callman = None
|
||||
|
||||
def close(self,*obj):
|
||||
self._cleanup_db_connects()
|
||||
ManagedWindow.ManagedWindow.close(self)
|
||||
self._cleanup_on_exit()
|
||||
|
||||
def _cleanup_db_connects(self):
|
||||
"""
|
||||
|
@ -118,6 +118,7 @@ class EditSecondary(ManagedWindow.ManagedWindow, DbGUIElement):
|
||||
self.uistate = None
|
||||
self.obj = None
|
||||
self.db = None
|
||||
self.callback = None
|
||||
self.callman.database = None
|
||||
self.callman = None
|
||||
|
||||
|
@ -158,39 +158,39 @@ class EditSourceRef(EditReference):
|
||||
self._add_tab(notebook_src, self.primtab)
|
||||
self._add_tab(notebook_ref, self.reftab)
|
||||
|
||||
self.note_tab = self._add_tab(
|
||||
notebook_src,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.source.get_note_list(),
|
||||
notetype=gen.lib.NoteType.SOURCE))
|
||||
|
||||
self.gallery_tab = self._add_tab(
|
||||
notebook_src,
|
||||
GalleryTab(self.dbstate, self.uistate, self.track,
|
||||
self.source.get_media_list()))
|
||||
|
||||
self.data_tab = self._add_tab(
|
||||
notebook_src,
|
||||
DataEmbedList(self.dbstate, self.uistate, self.track,
|
||||
self.source))
|
||||
|
||||
self.repo_tab = self._add_tab(
|
||||
notebook_src,
|
||||
RepoEmbedList(self.dbstate, self.uistate, self.track,
|
||||
self.source.get_reporef_list()))
|
||||
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook_src,
|
||||
SourceBackRefList(self.dbstate,self.uistate, self.track,
|
||||
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.source.get_note_list(),
|
||||
notetype=gen.lib.NoteType.SOURCE)
|
||||
self._add_tab(notebook_src, self.note_tab)
|
||||
self.track_ref_for_deletion("note_tab")
|
||||
|
||||
self.gallery_tab = GalleryTab(self.dbstate, self.uistate, self.track,
|
||||
self.source.get_media_list())
|
||||
self._add_tab(notebook_src, self.gallery_tab)
|
||||
self.track_ref_for_deletion("gallery_tab")
|
||||
|
||||
self.data_tab = DataEmbedList(self.dbstate, self.uistate, self.track,
|
||||
self.source)
|
||||
self._add_tab(notebook_src, self.data_tab)
|
||||
self.track_ref_for_deletion("data_tab")
|
||||
|
||||
self.repo_tab = RepoEmbedList(self.dbstate, self.uistate, self.track,
|
||||
self.source.get_reporef_list())
|
||||
self._add_tab(notebook_src, self.repo_tab)
|
||||
self.track_ref_for_deletion("repo_tab")
|
||||
|
||||
self.srcref_list = SourceBackRefList(self.dbstate,self.uistate, self.track,
|
||||
self.db.find_backlink_handles(self.source.handle),
|
||||
self.enable_warnbox
|
||||
))
|
||||
)
|
||||
self._add_tab(notebook_src, self.srcref_list)
|
||||
self.track_ref_for_deletion("srcref_list")
|
||||
|
||||
self.comment_tab = self._add_tab(
|
||||
notebook_ref,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.comment_tab = NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.source_ref.get_note_list(),
|
||||
notetype=gen.lib.NoteType.SOURCEREF))
|
||||
notetype=gen.lib.NoteType.SOURCEREF)
|
||||
self._add_tab(notebook_ref, self.comment_tab)
|
||||
self.track_ref_for_deletion("comment_tab")
|
||||
|
||||
self._setup_notebook_tabs( notebook_src)
|
||||
self._setup_notebook_tabs( notebook_ref)
|
||||
|
@ -69,9 +69,12 @@ class BaseSelector(ManagedWindow.ManagedWindow):
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
||||
|
||||
self.renderer = gtk.CellRendererText()
|
||||
self.track_ref_for_deletion("renderer")
|
||||
self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END)
|
||||
|
||||
self.db = dbstate.db
|
||||
self.tree = None
|
||||
self.model = None
|
||||
|
||||
self.glade = Glade()
|
||||
|
||||
@ -103,6 +106,7 @@ class BaseSelector(ManagedWindow.ManagedWindow):
|
||||
self.skip_list=skip
|
||||
self.build_tree()
|
||||
self.selection = self.tree.get_selection()
|
||||
self.track_ref_for_deletion("selection")
|
||||
|
||||
self._local_init()
|
||||
self._set_size()
|
||||
@ -184,14 +188,15 @@ class BaseSelector(ManagedWindow.ManagedWindow):
|
||||
|
||||
def run(self):
|
||||
val = self.window.run()
|
||||
result = None
|
||||
if val == gtk.RESPONSE_OK:
|
||||
id_list = self.get_selected_ids()
|
||||
self.close()
|
||||
if id_list and id_list[0]:
|
||||
return self.get_from_handle_func()(id_list[0])
|
||||
result = self.get_from_handle_func()(id_list[0])
|
||||
self.close()
|
||||
elif val != gtk.RESPONSE_DELETE_EVENT:
|
||||
self.close()
|
||||
return None
|
||||
return result
|
||||
|
||||
def _on_row_activated(self, treeview, path, view_col):
|
||||
self.window.response(gtk.RESPONSE_OK)
|
||||
@ -287,6 +292,7 @@ class BaseSelector(ManagedWindow.ManagedWindow):
|
||||
self.add_columns(self.tree)
|
||||
|
||||
#reset the model with correct sorting
|
||||
self.clear_model()
|
||||
self.model = self.get_model_class()(self.db, self.sort_col,
|
||||
self.sortorder,
|
||||
sort_map=self.column_order(),
|
||||
@ -331,7 +337,7 @@ class BaseSelector(ManagedWindow.ManagedWindow):
|
||||
|
||||
def show_toggle(self, obj):
|
||||
filter_info = None if obj.get_active() else self.filter
|
||||
|
||||
self.clear_model()
|
||||
self.model = self.get_model_class()(self.db, self.sort_col,
|
||||
self.sortorder,
|
||||
sort_map=self.column_order(),
|
||||
@ -339,3 +345,24 @@ class BaseSelector(ManagedWindow.ManagedWindow):
|
||||
search=filter_info)
|
||||
self.tree.set_model(self.model)
|
||||
self.tree.grab_focus()
|
||||
|
||||
def clear_model(self):
|
||||
if self.model:
|
||||
self.tree.set_model(None)
|
||||
if hasattr(self.model, 'destroy'):
|
||||
self.model.destroy()
|
||||
self.model = None
|
||||
|
||||
def _cleanup_on_exit(self):
|
||||
"""Unset all things that can block garbage collection.
|
||||
Finalize rest
|
||||
"""
|
||||
self.clear_model()
|
||||
self.db = None
|
||||
self.tree = None
|
||||
self.columns = None
|
||||
self.search_bar.destroy()
|
||||
|
||||
def close(self, *obj):
|
||||
ManagedWindow.ManagedWindow.close(self)
|
||||
self._cleanup_on_exit()
|
||||
|
@ -178,6 +178,11 @@ class NodeMap(object):
|
||||
"""
|
||||
Unset all elements that can prevent garbage collection
|
||||
"""
|
||||
## for key, item in self.id2node.iteritems():
|
||||
## item.prev = None
|
||||
## item.next = None
|
||||
## item.parent = None
|
||||
## item.children = []
|
||||
self.id2node.clear()
|
||||
|
||||
def add_node(self, node):
|
||||
@ -328,7 +333,9 @@ class TreeBaseModel(gtk.GenericTreeModel):
|
||||
self.rebuild_data = None
|
||||
self._build_data = None
|
||||
self.search = None
|
||||
self.current_filter = None
|
||||
self.clear_cache()
|
||||
self.lru_data = None
|
||||
|
||||
def _set_base_data(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user