4340: Error when adding source reference

svn: r16111
This commit is contained in:
Benny Malengier 2010-11-02 13:19:27 +00:00
parent 02db3c69af
commit 11411b4885
5 changed files with 66 additions and 4 deletions

View File

@ -66,7 +66,7 @@ class BackRefList(EmbeddedList):
EmbeddedList.__init__(self, dbstate, uistate, track,
_('_References'), refmodel)
self._callback = callback
self.model.connect('row-inserted', self.update_label)
self.connectid = self.model.connect('row-inserted', self.update_label)
self.track_ref_for_deletion("model")
def update_label(self, *obj):
@ -78,8 +78,8 @@ class BackRefList(EmbeddedList):
def right_click(self, obj, event):
return
def close(self):
self.model.close()
def _cleanup_local_connects(self):
self.model.disconnect(self.connectid)
def is_empty(self):
return self.model.count == 0

View File

@ -54,10 +54,18 @@ class BackRefModel(gtk.ListStore):
self.count = 0
self.idle = gobject.idle_add(self.load_model().next)
def close(self):
def destroy(self):
gobject.source_remove(self.idle)
def load_model(self):
"""
Objects can have very large backreferences. To avoid blocking the
interface up to the moment that the model is created, this method is
called via gobject.idle_add.
WARNING: a consequence of above is that loading can still be happening
while the GUI using this model is no longer used. Disconnect any
methods before closing the GUI.
"""
self.count = 0
for ref in self.sref_list:
self.count += 1

View File

@ -178,6 +178,7 @@ class EditPrimary(ManagedWindow.ManagedWindow, DbGUIElement):
def _do_close(self, *obj):
self._cleanup_db_connects()
self.dbstate.disconnect(self.dbstate_connect_key)
self._cleanup_connects()
self._cleanup_on_exit()
self.get_from_handle = None
self.get_from_gramps_id = None
@ -198,6 +199,23 @@ class EditPrimary(ManagedWindow.ManagedWindow, DbGUIElement):
for tab in self.__tabs:
if hasattr(tab, 'callman'):
tab._cleanup_callbacks()
def _cleanup_connects(self):
"""
Connects to interface elements to things outside the element should be
removed before destroying the interface
"""
self._cleanup_local_connects()
for tab in [tab for tab in self.__tabs if hasattr(tab, '_cleanup_local_connects')]:
tab._cleanup_local_connects()
def _cleanup_local_connects(self):
"""
Connects to interface elements to things outside the element should be
removed before destroying the interface. This methods cleans connects
of the main interface, not of the displaytabs.
"""
pass
def check_for_close(self, handles):
"""

View File

@ -223,6 +223,7 @@ class EditReference(ManagedWindow.ManagedWindow, DbGUIElement):
def close(self,*obj):
self._cleanup_db_connects()
self._cleanup_connects()
ManagedWindow.ManagedWindow.close(self)
self._cleanup_on_exit()
@ -237,3 +238,20 @@ class EditReference(ManagedWindow.ManagedWindow, DbGUIElement):
self._cleanup_callbacks()
for tab in [tab for tab in self.__tabs if hasattr(tab, 'callman')]:
tab._cleanup_callbacks()
def _cleanup_connects(self):
"""
Connects to interface elements to things outside the element should be
removed before destroying the interface
"""
self._cleanup_local_connects()
for tab in [tab for tab in self.__tabs if hasattr(tab, '_cleanup_local_connects')]:
tab._cleanup_local_connects()
def _cleanup_local_connects(self):
"""
Connects to interface elements to things outside the element should be
removed before destroying the interface. This methods cleans connects
of the main interface, not of the displaytabs.
"""
pass

View File

@ -142,6 +142,7 @@ class EditSecondary(ManagedWindow.ManagedWindow, DbGUIElement):
def close(self, *obj):
self._cleanup_db_connects()
self._cleanup_connects()
ManagedWindow.ManagedWindow.close(self)
self._cleanup_on_exit()
@ -156,3 +157,20 @@ class EditSecondary(ManagedWindow.ManagedWindow, DbGUIElement):
self._cleanup_callbacks()
for tab in [tab for tab in self.__tabs if hasattr(tab, 'callman')]:
tab._cleanup_callbacks()
def _cleanup_connects(self):
"""
Connects to interface elements to things outside the element should be
removed before destroying the interface
"""
self._cleanup_local_connects()
for tab in [tab for tab in self.__tabs if hasattr(tab, '_cleanup_local_connects')]:
tab._cleanup_local_connects()
def _cleanup_local_connects(self):
"""
Connects to interface elements to things outside the element should be
removed before destroying the interface. This methods cleans connects
of the main interface, not of the displaytabs.
"""
pass