From 213c6a9298acd0bc61f4809bf624d0064dbc85e0 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Sat, 29 Sep 2007 12:04:45 +0000 Subject: [PATCH] 2007-09-29 James G. Sack * src/GrampsDb/_ReadXML.py: remove bug: no more creation of objects if bookmark is found with handle that is not in database. This causes corruption of database! * src/GrampsDb/_GrampsDbBase.py: person bookmarks do not work after save. Correct. Issue #1260 svn: r9035 --- ChangeLog | 5 +++++ src/GrampsDb/_GrampsXMLDB.py | 2 -- src/GrampsDb/_ReadXML.py | 32 ++++++++++++++++++-------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7eb575bb7..3ed2b64fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-09-29 James G. Sack + * src/GrampsDb/_ReadXML.py: remove bug: no more creation of objects if bookmark is found with + handle that is not in database. This causes corruption of database! + * src/GrampsDb/_GrampsDbBase.py: person bookmarks do not work after save. Correct. Issue #1260 + 2007-09-28 James G. Sack * src/RecentFiles.py: * src/GrampsDb/_GrampsDbBase.py: diff --git a/src/GrampsDb/_GrampsXMLDB.py b/src/GrampsDb/_GrampsXMLDB.py index db121037e..b7c714690 100644 --- a/src/GrampsDb/_GrampsXMLDB.py +++ b/src/GrampsDb/_GrampsXMLDB.py @@ -44,7 +44,6 @@ class GrampsXMLDB(GrampsInMemDB): def __init__(self, use_txn = True): """creates a new GrampsDB""" GrampsInMemDB.__init__(self) - self.bookmarks = GrampsDbBookmarks() def load(self, name, callback, mode="w"): @@ -58,7 +57,6 @@ class GrampsXMLDB(GrampsInMemDB): except OSError, IOError: return 1 - self.bookmarks.set(self.metadata.get('bookmarks',[])) self.db_is_open = True self.abort_possible = True return 1 diff --git a/src/GrampsDb/_ReadXML.py b/src/GrampsDb/_ReadXML.py index f71b50d9b..9e9ca1371 100644 --- a/src/GrampsDb/_ReadXML.py +++ b/src/GrampsDb/_ReadXML.py @@ -840,27 +840,31 @@ class GrampsParser(UpdateCallback): # This is new XML, so we are guaranteed to have a handle ref handle = attrs['hlink'].replace('_','') + # Due to pre 2.2.9 bug, bookmarks might be handle of other object + # Make sure those are filtered out. + # Bookmarks are at end, so all handle must exist before we do bookmrks if target == 'person': - self.db.check_person_from_handle(handle,self.trans) - self.db.bookmarks.append(handle) + if self.db.find_person_from_handle(handle,self.trans) is not None: + self.db.bookmarks.append(handle) elif target == 'family': - self.db.check_family_from_handle(handle,self.trans) - self.db.family_bookmarks.append(handle) + if self.db.find_family_from_handle(handle,self.trans) is not None: + self.db.family_bookmarks.append(handle) elif target == 'event': - self.db.check_event_from_handle(handle,self.trans) - self.db.event_bookmarks.append(handle) + if self.db.find_event_from_handle(handle,self.trans) is not None: + self.db.event_bookmarks.append(handle) + print self.db.event_bookmarks.get() elif target == 'source': - self.db.check_source_from_handle(handle,self.trans) - self.db.source_bookmarks.append(handle) + if self.db.find_source_from_handle(handle,self.trans) is not None: + self.db.source_bookmarks.append(handle) elif target == 'place': - self.db.check_place_from_handle(handle,self.trans) - self.db.place_bookmarks.append(handle) + if self.db.find_place_from_handle(handle,self.trans) is not None: + self.db.place_bookmarks.append(handle) elif target == 'media': - self.db.check_object_from_handle(handle,self.trans) - self.db.media_bookmarks.append(handle) + if self.db.find_object_from_handle(handle,self.trans) is not None: + self.db.media_bookmarks.append(handle) elif target == 'repository': - self.db.check_repository_from_handle(handle,self.trans) - self.db.repo_bookmarks.append(handle) + if self.db.find_repository_from_handle(handle,self.trans) is not None: + self.db.repo_bookmarks.append(handle) def start_format(self,attrs): number = int(attrs['number'])