Fix Adding "ToDo" note crash when no active object (#685)

* Fix Adding "ToDo" note crash when no active object

Fixes #10795

* Better message when no active object.

* resolve conflict: Fixes #10795
This commit is contained in:
Serge Noiraud
2018-11-28 12:58:46 +01:00
committed by GitHub
parent 38bfb760a3
commit 8c35277267

View File

@ -32,6 +32,7 @@ from gi.repository import Gtk
from gramps.gen.plug import Gramplet
from gramps.gui.widgets.styledtexteditor import StyledTextEditor
from gramps.gui.widgets import SimpleButton
from gramps.gui.dialog import WarningDialog
from gramps.gen.lib import StyledText, Note, NoteType
from gramps.gen.db import DbTxn
from gramps.gen.errors import WindowActiveError
@ -185,6 +186,9 @@ class ToDo(Gramplet):
"""
Create a new To Do note.
"""
nav_type = self.uistate.viewmanager.active_page.navigation_type()
active_handle = self.get_active(nav_type)
if active_handle:
from gramps.gui.editors import EditNote
note = Note()
note.set_type(NoteType.TODO)
@ -192,6 +196,11 @@ class ToDo(Gramplet):
EditNote(self.gui.dbstate, self.gui.uistate, [], note, self.created)
except WindowActiveError:
pass
else:
WarningDialog(_("No active object"),
_("First select the object to which you want to attach a note")
+ _(":") + _(nav_type),
parent=self.uistate.window)
class PersonToDo(ToDo):
"""