From 8da903e032f607e16db41adff91e3fa3f511b92d Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 15 Apr 2005 04:50:15 +0000 Subject: [PATCH] * src/plugins/Check.py: loop through family relationships until all problems are resolved svn: r4364 --- ChangeLog | 2 ++ src/FamilyView.py | 34 ++++++++++++++++++++-------------- src/plugins/Check.py | 20 ++++++++++++++++---- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea55ffc51..be5258c1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ 2005-04-14 Don Allingham + * src/plugins/Check.py: loop through family relationships until all + problems are resolved * src/FamilyView.py: make load_family more robust to signals 2005-04-14 Martin Hawlisch diff --git a/src/FamilyView.py b/src/FamilyView.py index 8bed7201b..fb0d6190d 100644 --- a/src/FamilyView.py +++ b/src/FamilyView.py @@ -1028,7 +1028,8 @@ class FamilyView: sp = self.parent.db.get_person_from_handle(sp_id) event = self.find_marriage(fm) if event: - mdate = " - %s" % DateHandler.displayer.display(event.get_date_object()) + dobj = event.get_date_object() + mdate = " - %s" % DateHandler.displayer.display(dobj) else: mdate = "" v = "%s [%s]\n\t%s%s" % ( @@ -1041,19 +1042,24 @@ class FamilyView: self.spouse_model.set(node,0,"%s\n" % _("")) self.spouse_model.set(node,1,f) - - if family and family.get_handle() in flist: - self.display_marriage(family) - node = flist[family.get_handle()] - self.spouse_selection.select_iter(node) - elif len(flist) > 0: - fid = splist[0] - fam = self.parent.db.get_family_from_handle(fid) - self.display_marriage(fam) - node = flist[fid] - self.spouse_selection.select_iter(node) - else: - self.display_marriage(None) + try: + if family and family.get_handle() in flist: + self.display_marriage(family) + node = flist[family.get_handle()] + self.spouse_selection.select_iter(node) + elif len(flist) > 0: + fid = splist[0] + fam = self.parent.db.get_family_from_handle(fid) + self.display_marriage(fam) + node = flist[fid] + self.spouse_selection.select_iter(node) + else: + self.display_marriage(None) + except KeyError: + WarningDialog(_('Database corruption detected'), + _('A problem was detected with the database. Please ' + 'run the Check and Repair Database tool to fix the ' + 'problem.')) self.update_list(self.ap_parents_model,self.ap_parents,person) diff --git a/src/plugins/Check.py b/src/plugins/Check.py index a6866f70e..085e5d0bf 100644 --- a/src/plugins/Check.py +++ b/src/plugins/Check.py @@ -61,10 +61,20 @@ def runTool(database,active_person,callback,parent=None): trans.set_batch(True) database.disable_signals() checker = CheckIntegrity(database,parent,trans) - checker.check_for_broken_family_links() checker.cleanup_missing_photos(0) - checker.check_parent_relationships() - checker.cleanup_empty_families(0) + + prev_total = -1 + total = 0 + + while prev_total != total: + prev_total = total + + checker.check_for_broken_family_links() + checker.check_parent_relationships() + checker.cleanup_empty_families(0) + + total = checker.family_errors() + checker.check_events() checker.check_place_references() database.transaction_commit(trans, _("Check Integrity")) @@ -101,8 +111,10 @@ class CheckIntegrity: self.invalid_death_events = [] self.invalid_place_references = [] + def family_errors(self): + return len(self.broken_parent_links) + len(self.broken_links) + len(self.empty_family) + def check_for_broken_family_links(self): - self.broken_links = [] # Check persons referenced by the family objects for family_handle in self.db.get_family_handles(): family = self.db.get_family_from_handle(family_handle)