Prevent removing idle process after it has finished

This commit is contained in:
Nick Hall 2014-05-14 00:52:04 +01:00
parent 620dca433f
commit 786a8f86f3

View File

@ -56,13 +56,15 @@ class BackRefModel(Gtk.ListStore):
self.db = db self.db = db
self.sref_list = sref_list self.sref_list = sref_list
self.count = 0 self.count = 0
self.loading = False
if sys.version_info[0] < 3: if sys.version_info[0] < 3:
self.idle = GObject.idle_add(self.load_model().next) self.idle = GObject.idle_add(self.load_model().next)
else: else:
self.idle = GObject.idle_add(self.load_model().__next__) self.idle = GObject.idle_add(self.load_model().__next__)
def destroy(self): def destroy(self):
GObject.source_remove(self.idle) if self.loading:
GObject.source_remove(self.idle)
def load_model(self): def load_model(self):
""" """
@ -73,6 +75,7 @@ class BackRefModel(Gtk.ListStore):
while the GUI using this model is no longer used. Disconnect any while the GUI using this model is no longer used. Disconnect any
methods before closing the GUI. methods before closing the GUI.
""" """
self.loading = True
self.count = 0 self.count = 0
for ref in self.sref_list: for ref in self.sref_list:
self.count += 1 self.count += 1
@ -149,4 +152,5 @@ class BackRefModel(Gtk.ListStore):
# but we don't need to show that in the view. # but we don't need to show that in the view.
self.append(row=[_(dtype), gid, name, handle, dtype]) self.append(row=[_(dtype), gid, name, handle, dtype])
yield True yield True
self.loading = False
yield False yield False