Protection from null objects
This commit is contained in:
parent
429b91d357
commit
202e1f5594
@ -1922,9 +1922,8 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
def iter_sources(self, order_by=None):
|
def iter_sources(self, order_by=None):
|
||||||
return self.iter_items(order_by, Source)
|
return self.iter_items(order_by, Source)
|
||||||
|
|
||||||
def iter_tags(self):
|
def iter_tags(self, order_by=None):
|
||||||
return (Tag.create(data[1]) for data in self.get_tag_cursor())
|
return self.iter_items(order_by, Tag)
|
||||||
|
|
||||||
|
|
||||||
def set_prefixes(self, person, media, family, source, citation,
|
def set_prefixes(self, person, media, family, source, citation,
|
||||||
place, event, repository, note):
|
place, event, repository, note):
|
||||||
|
@ -161,10 +161,12 @@ def insert_image(database, doc, photo, user,
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def find_spouse(person, family):
|
def find_spouse(person, family):
|
||||||
if person.get_handle() == family.get_father_handle():
|
spouse_handle = None
|
||||||
spouse_handle = family.get_mother_handle()
|
if family:
|
||||||
else:
|
if person.get_handle() == family.get_father_handle():
|
||||||
spouse_handle = family.get_father_handle()
|
spouse_handle = family.get_mother_handle()
|
||||||
|
else:
|
||||||
|
spouse_handle = family.get_father_handle()
|
||||||
return spouse_handle
|
return spouse_handle
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -393,8 +393,9 @@ def find_children(db,p):
|
|||||||
childlist = []
|
childlist = []
|
||||||
for family_handle in p.get_family_handle_list():
|
for family_handle in p.get_family_handle_list():
|
||||||
family = db.get_family_from_handle(family_handle)
|
family = db.get_family_from_handle(family_handle)
|
||||||
for child_ref in family.get_child_ref_list():
|
if family:
|
||||||
childlist.append(child_ref.ref)
|
for child_ref in family.get_child_ref_list():
|
||||||
|
childlist.append(child_ref.ref)
|
||||||
return childlist
|
return childlist
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -75,6 +75,8 @@ class PersonEventEmbedList(EventEmbedList):
|
|||||||
if family_handle_list:
|
if family_handle_list:
|
||||||
for family_handle in family_handle_list:
|
for family_handle in family_handle_list:
|
||||||
family = self.dbstate.db.get_family_from_handle(family_handle)
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||||
|
if family is None:
|
||||||
|
continue
|
||||||
father_handle = family.get_father_handle()
|
father_handle = family.get_father_handle()
|
||||||
mother_handle = family.get_mother_handle()
|
mother_handle = family.get_mother_handle()
|
||||||
if self.obj.get_handle() == father_handle:
|
if self.obj.get_handle() == father_handle:
|
||||||
|
@ -187,12 +187,13 @@ class Citations(Gramplet, DbGUIElement):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def check_eventref_citations(self, obj):
|
def check_eventref_citations(self, obj):
|
||||||
for event_ref in obj.get_event_ref_list():
|
if obj:
|
||||||
if self.check_attribute_citations(event_ref):
|
for event_ref in obj.get_event_ref_list():
|
||||||
return True
|
if self.check_attribute_citations(event_ref):
|
||||||
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
return True
|
||||||
if self.check_event_citations(event):
|
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
||||||
return True
|
if self.check_event_citations(event):
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_event_citations(self, event):
|
def check_event_citations(self, event):
|
||||||
|
@ -212,9 +212,9 @@ class PersonEvents(Events):
|
|||||||
spouse = self.dbstate.db.get_person_from_handle(spouse_handle)
|
spouse = self.dbstate.db.get_person_from_handle(spouse_handle)
|
||||||
else:
|
else:
|
||||||
spouse = None
|
spouse = None
|
||||||
|
if family:
|
||||||
for event_ref in family.get_event_ref_list():
|
for event_ref in family.get_event_ref_list():
|
||||||
self.add_event_ref(event_ref, spouse)
|
self.add_event_ref(event_ref, spouse)
|
||||||
|
|
||||||
def get_start_date(self):
|
def get_start_date(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user