From cff726a4bb13fc70c1723f1ae200faeb7ca5254d Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 12 Dec 2015 21:51:25 +0000 Subject: [PATCH] More empty handle checks in proxies --- gramps/gen/proxy/living.py | 8 +++++--- gramps/gen/proxy/private.py | 14 ++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/gramps/gen/proxy/living.py b/gramps/gen/proxy/living.py index d82915284..740e5fe65 100644 --- a/gramps/gen/proxy/living.py +++ b/gramps/gen/proxy/living.py @@ -146,13 +146,15 @@ class LivingProxyDb(ProxyDbBase): def get_default_person(self): """returns the default Person of the database""" person_handle = self.db.get_default_handle() - return self.get_person_from_handle(person_handle) + if person_handle: + return self.get_person_from_handle(person_handle) + return None def get_default_handle(self): """returns the default Person of the database""" person_handle = self.db.get_default_handle() - if self.get_person_from_handle(person_handle): - return person_handle + if person_handle and self.get_person_from_handle(person_handle): + return person_handle return None def has_person_handle(self, handle): diff --git a/gramps/gen/proxy/private.py b/gramps/gen/proxy/private.py index ac3ed0459..e85abbe65 100644 --- a/gramps/gen/proxy/private.py +++ b/gramps/gen/proxy/private.py @@ -312,9 +312,10 @@ class PrivateProxyDb(ProxyDbBase): def get_default_handle(self): """returns the default Person of the database""" handle = self.db.get_default_handle() - person = self.db.get_person_from_handle(handle) - if person and not person.get_privacy(): - return handle + if handle: + person = self.db.get_person_from_handle(handle) + if person and not person.get_privacy(): + return handle return None def has_person_handle(self, handle): @@ -640,9 +641,10 @@ def sanitize_lds_ord(db, lds_ord): new_lds_ord.set_temple(lds_ord.get_temple()) fam_handle = lds_ord.get_family_handle() - fam = db.get_family_from_handle(fam_handle) - if fam and not fam.get_privacy(): - new_lds_ord.set_family_handle(fam_handle) + if fam_handle: + fam = db.get_family_from_handle(fam_handle) + if fam and not fam.get_privacy(): + new_lds_ord.set_family_handle(fam_handle) new_lds_ord.set_date_object(lds_ord.get_date_object())