From 320044c377cdf11a748a77d3c5343fcf38e6ce1b Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Sat, 8 Sep 2012 22:22:43 +0000 Subject: [PATCH] Fix two bugs in fanchart: crash on empty famtree, empty events show year 0 svn: r20354 --- src/gen/utils/db.py | 15 ++++++++++----- src/gui/widgets/fanchart.py | 5 ++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/gen/utils/db.py b/src/gen/utils/db.py index b0adc5b9a..e60caec05 100644 --- a/src/gen/utils/db.py +++ b/src/gen/utils/db.py @@ -117,10 +117,12 @@ def get_age(db, person, fallback=True, calendar="gregorian"): age = None if birth is not None: birth_date = birth.get_date_object().to_calendar("gregorian") - if (birth_date and birth_date.get_valid()): + if (birth_date and birth_date.get_valid() + and not birth_date.is_empty()): if death is not None: death_date = death.get_date_object().to_calendar("gregorian") - if (death_date and death_date.get_valid()): + if (death_date and death_date.get_valid() + and not death_date.is_empty()): age = death_date - birth_date if not age.is_valid(): age = None @@ -141,13 +143,15 @@ def get_timeperiod(db, person): birth = get_birth_or_fallback(db, person) if birth is not None: birth_date = birth.get_date_object().to_calendar("gregorian") - if (birth_date and birth_date.get_valid()): + if (birth_date and birth_date.get_valid() + and not birth_date.is_empty()): return birth_date.get_year() death = get_death_or_fallback(db, person) # no birth, period is death - 20 if death is not None: death_date = death.get_date_object().to_calendar("gregorian") - if (death_date and death_date.get_valid()): + if (death_date and death_date.get_valid() + and not death_date.is_empty()): return death_date.get_year() - 20 # no birth and death, look for another event date we can use for event_ref in person.get_primary_event_ref_list(): @@ -155,7 +159,8 @@ def get_timeperiod(db, person): event = db.get_event_from_handle(event_ref.ref) if event: event_date = event.get_date_object().to_calendar("gregorian") - if (event_date and event_date.get_valid()): + if (event_date and event_date.get_valid() + and not event_date.is_empty()): return event_date.get_year() return None diff --git a/src/gui/widgets/fanchart.py b/src/gui/widgets/fanchart.py index b52330ae9..5cf65f98d 100644 --- a/src/gui/widgets/fanchart.py +++ b/src/gui/widgets/fanchart.py @@ -602,7 +602,10 @@ class FanChartWidget(Gtk.DrawingArea): cr.stroke() #now again to fill person = self.dbstate.db.get_person_from_handle(child_handle) - r, g, b, a = self.background_box(person, person.gender, -1, userdata) + if person: + r, g, b, a = self.background_box(person, person.gender, -1, userdata) + else: + r=255; g=255; b=255; a=1 cr.move_to(rmin*math.cos(thetamin), rmin*math.sin(thetamin)) cr.arc(0, 0, rmin, thetamin, thetamax) cr.line_to(rmax*math.cos(thetamax), rmax*math.sin(thetamax))