diff --git a/ChangeLog b/ChangeLog index 1a19fb169..1f6769d04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-10-05 Benny Malengier + * src/DisplayTabs/_GalleryTab.py: remove bug that leads to database corruption, + if media is deleted in mediaview, remove media in all open gallery tabs + 2007-10-05 Benny Malengier * src/GrampsDb/_ReadGedcom.py: issue #1169, wrong GEDCOM parse ADDR diff --git a/src/DisplayTabs/_GalleryTab.py b/src/DisplayTabs/_GalleryTab.py index 0a77f4d42..9f39ff2c3 100644 --- a/src/DisplayTabs/_GalleryTab.py +++ b/src/DisplayTabs/_GalleryTab.py @@ -77,6 +77,9 @@ class GalleryTab(ButtonTab): self.rebuild() self.show_all() + + #connect external remove of object to rebuild + self.dbstate.db.connect('media-delete',self.media_delete) def double_click(self, obj, event): """ @@ -269,6 +272,26 @@ class GalleryTab(ButtonTab): def edit_callback(self, media_ref, ref): self.changed = True self.rebuild() + + def media_delete(self, del_media_handle_list): + """ + Outside of this tab media objects have been deleted. Check if tab + and object must be changed. + Note: delete of object will cause reference on database to be removed, + so this method need not do this + """ + ref_handles = [x.ref for x in self.media_list] + for handle in del_media_handle_list : + pos = None + try : + pos = ref_handles.index(handle) + except ValueError : + continue + + if pos is not None: + #oeps, we need to remove this reference, and rebuild tab + self.media_list.remove(self.media_list[pos]) + self.rebuild() def _set_dnd(self): """