From 38751bb5a8c88abd988a51d54813c972784e78ba Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Fri, 20 May 2005 20:05:55 +0000 Subject: [PATCH] * src/WriteGedcom.py: Some hardening against corrupt database. svn: r4643 --- gramps2/ChangeLog | 1 + gramps2/src/WriteGedcom.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 3ad2346ac..b69ce9dda 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,6 +1,7 @@ 2005-05-20 Martin Hawlisch * src/WriteXML.py: Remove unnecessary database reads, so it does no longer crash when exporting a corrupt database. + * src/WriteGedcom.py: Some hardening against corrupt database. 2005-05-20 Alex Roitman * src/SelectObject.py (on_select_row): Properly get mime type. diff --git a/gramps2/src/WriteGedcom.py b/gramps2/src/WriteGedcom.py index e8709fa66..094c0abb4 100644 --- a/gramps2/src/WriteGedcom.py +++ b/gramps2/src/WriteGedcom.py @@ -136,6 +136,8 @@ def add_persons_sources(db,person,slist,private): for event_handle in elist: if event_handle: event = db.get_event_from_handle(event_handle) + if not event: + continue if private and event.get_privacy(): continue for source_ref in event.get_source_references(): @@ -713,6 +715,8 @@ class GedcomWriter: if not self.plist.has_key(person_handle): continue person = self.db.get_person_from_handle(person_handle) + if not person: + continue self.writeln("1 CHIL @%s@" % person.get_gramps_id()) if self.adopt == GedcomInfo.ADOPT_FTW: if person.get_main_parents_family_handle() == family.get_handle(): @@ -737,6 +741,8 @@ class GedcomWriter: sorted = [] for key in self.slist.keys(): source = self.db.get_source_from_handle(key) + if not source: + continue data = (self.sid (source.get_gramps_id ()), source) sorted.append (data) sorted.sort () @@ -791,7 +797,7 @@ class GedcomWriter: if not restricted: birth_handle = person.get_birth_handle() birth = self.db.get_event_from_handle(birth_handle) - if birth_handle and not (self.private and birth.get_privacy()): + if birth_handle and birth and not (self.private and birth.get_privacy()): if not birth.get_date_object().is_empty() or birth.get_place_handle(): if birth.get_description() != "": self.writeln("1 BIRT %s" % birth.get_description()) @@ -801,7 +807,7 @@ class GedcomWriter: death_handle = person.get_death_handle() death = self.db.get_event_from_handle(death_handle) - if death_handle and not (self.private and death.get_privacy()): + if death_handle and death and not (self.private and death.get_privacy()): if not death.get_date_object().is_empty() or death.get_place_handle(): if birth.get_description() != "": self.writeln("1 DEAT %s" % death.get_description()) @@ -819,6 +825,8 @@ class GedcomWriter: if not event_handle: continue event = self.db.get_event_from_handle(event_handle) + if not event: + continue if self.private and event.get_privacy(): continue name = event.get_name()