From f9da7ec19a8516fbc29bee89561a0cc834bfa0fc Mon Sep 17 00:00:00 2001 From: prculley Date: Tue, 7 Nov 2017 14:10:03 -0600 Subject: [PATCH] Fix Session Log for exception on closed db reference click --- gramps/gui/widgets/grampletpane.py | 4 ++++ gramps/plugins/gramplet/sessionloggramplet.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/gramps/gui/widgets/grampletpane.py b/gramps/gui/widgets/grampletpane.py index 561f833ea..0592a0e94 100644 --- a/gramps/gui/widgets/grampletpane.py +++ b/gramps/gui/widgets/grampletpane.py @@ -638,6 +638,8 @@ class GuiGramplet: for (tag, link_type, handle, tooltip) in self._tags: if iter.has_tag(tag): if link_type == 'Person': + if not self.dbstate.db.has_person_handle(handle): + return True person = self.dbstate.db.get_person_from_handle(handle) if person is not None: if event.button == 1: # left mouse @@ -699,6 +701,8 @@ class GuiGramplet: display_help(handle) return True elif link_type == 'Family': + if not self.dbstate.db.has_family_handle(handle): + return True family = self.dbstate.db.get_family_from_handle(handle) if family is not None: if event.button == 1: # left mouse diff --git a/gramps/plugins/gramplet/sessionloggramplet.py b/gramps/plugins/gramplet/sessionloggramplet.py index dd4e7ac7c..4da5da322 100644 --- a/gramps/plugins/gramplet/sessionloggramplet.py +++ b/gramps/plugins/gramplet/sessionloggramplet.py @@ -69,11 +69,17 @@ class LogGramplet(Gramplet): lambda handles: self.log('Family', 'Deleted', handles)) self.connect(self.dbstate.db, 'family-update', lambda handles: self.log('Family', 'Edited', handles)) + self.connect_signal('Person', self.active_changed) + self.connect_signal('Family', self.active_changed_family) def active_changed(self, handle): if handle: self.log('Person', 'Selected', [handle]) + def active_changed_family(self, handle): + if handle: + self.log('Family', 'Selected', [handle]) + def log(self, ltype, action, handles): for handle in set(handles): if self.last_log == (ltype, action, handle): @@ -90,6 +96,8 @@ class LogGramplet(Gramplet): for i in transaction.get_recnos(reverse=True): (obj_type, trans_type, hndl, old_data, dummy) = \ transaction.get_record(i) + if isinstance(hndl, bytes): + hndl = str(hndl, "utf-8") if (obj_type == PERSON_KEY and trans_type == TXNDEL and hndl == handle): person = Person() @@ -102,6 +110,8 @@ class LogGramplet(Gramplet): for i in transaction.get_recnos(reverse=True): (obj_type, trans_type, hndl, old_data, dummy) = \ transaction.get_record(i) + if isinstance(hndl, bytes): + hndl = str(hndl, "utf-8") if (obj_type == FAMILY_KEY and trans_type == TXNDEL and hndl == handle): family = Family()