Fix handle errors in gramplets
This commit is contained in:
parent
621bf1e1e9
commit
bde4b1bf10
@ -73,8 +73,8 @@ class Ancestor(Gramplet):
|
||||
"""
|
||||
if active_handle:
|
||||
person = self.dbstate.db.get_person_from_handle(active_handle)
|
||||
if person:
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
if family_handle:
|
||||
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||
if family and (family.get_father_handle() or
|
||||
family.get_mother_handle()):
|
||||
|
@ -20,6 +20,7 @@
|
||||
from gramps.gui.editors import EditPerson
|
||||
from gramps.gui.listmodel import ListModel, NOSORT
|
||||
from gramps.gen.plug import Gramplet
|
||||
from gramps.gen.plug.report.utils import find_spouse
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.display.name import displayer as name_displayer
|
||||
@ -128,19 +129,18 @@ class PersonChildren(Children):
|
||||
active_person = self.dbstate.db.get_person_from_handle(active_handle)
|
||||
for family_handle in active_person.get_family_handle_list():
|
||||
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||
self.display_family(family, active_handle)
|
||||
self.display_family(family, active_person)
|
||||
self.set_has_data(self.model.count > 0)
|
||||
|
||||
def display_family(self, family, active_handle):
|
||||
def display_family(self, family, active_person):
|
||||
"""
|
||||
Display the children of given family.
|
||||
"""
|
||||
father_handle = family.get_father_handle()
|
||||
mother_handle = family.get_mother_handle()
|
||||
if father_handle == active_handle:
|
||||
spouse = self.dbstate.db.get_person_from_handle(mother_handle)
|
||||
spouse_handle = find_spouse(active_person, family)
|
||||
if spouse_handle:
|
||||
spouse = self.dbstate.db.get_person_from_handle(spouse_handle)
|
||||
else:
|
||||
spouse = self.dbstate.db.get_person_from_handle(father_handle)
|
||||
spouse = None
|
||||
|
||||
for child_ref in family.get_child_ref_list():
|
||||
child = self.dbstate.db.get_person_from_handle(child_ref.ref)
|
||||
|
@ -21,6 +21,7 @@ from gramps.gui.editors import EditEvent
|
||||
from gramps.gen.lib import EventRoleType
|
||||
from gramps.gui.listmodel import ListModel, NOSORT
|
||||
from gramps.gen.plug import Gramplet
|
||||
from gramps.gen.plug.report.utils import find_spouse
|
||||
from gramps.gui.dbguielement import DbGUIElement
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
@ -199,16 +200,22 @@ class PersonEvents(Events):
|
||||
self.add_event_ref(event_ref)
|
||||
for family_handle in active_person.get_family_handle_list():
|
||||
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||
father_handle = family.get_father_handle()
|
||||
mother_handle = family.get_mother_handle()
|
||||
if father_handle == active_handle:
|
||||
spouse = self.dbstate.db.get_person_from_handle(mother_handle)
|
||||
else:
|
||||
spouse = self.dbstate.db.get_person_from_handle(father_handle)
|
||||
for event_ref in family.get_event_ref_list():
|
||||
self.add_event_ref(event_ref, spouse)
|
||||
self.display_family(family, active_person)
|
||||
self.set_has_data(self.model.count > 0)
|
||||
|
||||
def display_family(self, family, active_person):
|
||||
"""
|
||||
Display the events for the given family.
|
||||
"""
|
||||
spouse_handle = find_spouse(active_person, family)
|
||||
if spouse_handle:
|
||||
spouse = self.dbstate.db.get_person_from_handle(spouse_handle)
|
||||
else:
|
||||
spouse = None
|
||||
|
||||
for event_ref in family.get_event_ref_list():
|
||||
self.add_event_ref(event_ref, spouse)
|
||||
|
||||
def get_start_date(self):
|
||||
"""
|
||||
Get the start date for a person, usually a birth date, or
|
||||
|
Loading…
Reference in New Issue
Block a user