Fix Report Options when used with empty db (#554)

Fixes #10457
This commit is contained in:
Paul Culley 2018-02-23 16:37:36 -06:00 committed by Sam Manzi
parent 05dd44cfe2
commit 9c5951a9e9

View File

@ -55,6 +55,7 @@ from .. import widgets
from ..managedwindow import ManagedWindow from ..managedwindow import ManagedWindow
from ..dialog import OptionDialog from ..dialog import OptionDialog
from ..selectors import SelectorFactory from ..selectors import SelectorFactory
from gramps.gen.errors import HandleError
from gramps.gen.display.name import displayer as _nd from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd from gramps.gen.display.place import displayer as _pd
from gramps.gen.filters import GenericFilterFactory, GenericFilter, rules from gramps.gen.filters import GenericFilterFactory, GenericFilter, rules
@ -653,19 +654,22 @@ class GuiPersonOption(Gtk.Box):
gid = self.__option.get_value() gid = self.__option.get_value()
# Pick up the active person # Pick up the active person
person_handle = self.__uistate.get_active('Person') try:
person = self.__dbstate.db.get_person_from_handle(person_handle) person_handle = self.__uistate.get_active('Person')
person = self.__dbstate.db.get_person_from_handle(person_handle)
if override or not person: if override or not person:
# Pick up the stored option value if there is one # Pick up the stored option value if there is one
person = self.__db.get_person_from_gramps_id(gid) person = self.__db.get_person_from_gramps_id(gid)
if not person: if not person:
# If all else fails, get the default person to avoid bad values # If all else fails, get the default person to avoid bad values
person = self.__db.get_default_person() person = self.__db.get_default_person()
if not person: if not person:
person = self.__db.find_initial_person() person = self.__db.find_initial_person()
except HandleError:
person = None
self.__update_person(person) self.__update_person(person)