4340: Error when adding source reference

svn: r16109
This commit is contained in:
Benny Malengier 2010-11-02 13:12:27 +00:00
parent 77d3cf1967
commit e6f6d5d00c
3 changed files with 30 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

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