diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 2db1e8c80..f62767fe0 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -6,6 +6,10 @@ 2006-11-20 Martin Hawlisch * src/RelLib/_Family.py (get_sourcref_child_list): The ChildRefs were missing here. This now removes deleted Sources from ChildRefs. + * src/RelLib/_Person.py (_remove_handle_references): When removing a place dont + delete the whole LdsOrd but only unset its place reference. + * src/plugins/Check.py (check_place_references): Add checks for LdsOrd inside + Person and Family 2006-11-19 Don Allingham * src/Utils.py: probably_alive should onlyuse primary events diff --git a/gramps2/src/RelLib/_Person.py b/gramps2/src/RelLib/_Person.py index 5efa9136d..8a4ff6141 100644 --- a/gramps2/src/RelLib/_Person.py +++ b/gramps2/src/RelLib/_Person.py @@ -243,9 +243,9 @@ class Person(PrimaryObject,SourceBase,NoteBase,MediaBase, if handle not in handle_list ] self.parent_family_list = new_list elif classname == 'Place': - new_list = [ordinance for ordinance in self.lds_ord_list - if ordinance.place not in handle_list] - self.lds_ord_list = new_list + for ordinance in self.lds_ord_list: + if ordinance.place in handle_list: + ordinance.place = None def _replace_handle_reference(self, classname, old_handle, new_handle): if classname == 'Event': diff --git a/gramps2/src/plugins/Check.py b/gramps2/src/plugins/Check.py index f2bb6700e..1efd11edd 100644 --- a/gramps2/src/plugins/Check.py +++ b/gramps2/src/plugins/Check.py @@ -677,11 +677,36 @@ class CheckIntegrity: self.invalid_person_references.append(key) def check_place_references(self): + plist = self.db.get_person_handles() + flist = self.db.get_family_handles() elist = self.db.get_event_handles() - self.progress.set_pass(_('Looking for place reference problems'), - len(elist)) - + len(elist)+len(plist)+len(flist)) + # check persons -> the LdsOrd references a place + for key in plist: + person = self.db.get_person_from_handle(key) + for ordinance in person.lds_ord_list: + place_handle = ordinance.get_place_handle() + if place_handle: + place = self.db.get_place_from_handle(place_handle) + if not place: + # The referenced place does not exist in the database + ordinance.set_place_handle("") + self.db.commit_person(person,self.trans) + self.invalid_place_references.append(key) + # check families -> the LdsOrd references a place + for key in flist: + family = self.db.get_family_from_handle(key) + for ordinance in family.lds_ord_list: + place_handle = ordinance.get_place_handle() + if place_handle: + place = self.db.get_place_from_handle(place_handle) + if not place: + # The referenced place does not exist in the database + ordinance.set_place_handle("") + self.db.commit_family(family,self.trans) + self.invalid_place_references.append(key) + # check events for key in elist: event = self.db.get_event_from_handle(key) place_handle = event.get_place_handle()