7931: Fix check and repair tool for empty placerefs

This commit is contained in:
Enno Borgsteede 2014-09-25 22:06:55 +01:00 committed by Nick Hall
parent 26560d0590
commit c667cd5430

View File

@ -1241,8 +1241,14 @@ class CheckIntegrity(object):
for bkey in llist: for bkey in llist:
key = handle2internal(bkey) key = handle2internal(bkey)
self.progress.step() self.progress.step()
none_handle = False
newlist = []
place = self.db.get_place_from_handle(key) place = self.db.get_place_from_handle(key)
for placeref in place.get_placeref_list(): for placeref in place.get_placeref_list():
newlist.append(placeref)
if placeref.ref is None:
none_handle = True
placeref.ref = create_id()
parent_place = self.db.get_place_from_handle(placeref.ref) parent_place = self.db.get_place_from_handle(placeref.ref)
if not parent_place: if not parent_place:
# The referenced place does not exist in the database # The referenced place does not exist in the database
@ -1255,6 +1261,9 @@ class CheckIntegrity(object):
{'gid' : place.gramps_id, {'gid' : place.gramps_id,
'hand' : placeref.ref}) 'hand' : placeref.ref})
self.invalid_place_references.add(key) self.invalid_place_references.add(key)
if none_handle:
place.set_placeref_list(newlist);
self.db.commit_place(place, self.trans)
# check persons -> the LdsOrd references a place # check persons -> the LdsOrd references a place
for bkey in plist: for bkey in plist: