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:
parent
38bfb760a3
commit
8c35277267
@ -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,13 +186,21 @@ class ToDo(Gramplet):
|
||||
"""
|
||||
Create a new To Do note.
|
||||
"""
|
||||
from gramps.gui.editors import EditNote
|
||||
note = Note()
|
||||
note.set_type(NoteType.TODO)
|
||||
try:
|
||||
EditNote(self.gui.dbstate, self.gui.uistate, [], note, self.created)
|
||||
except WindowActiveError:
|
||||
pass
|
||||
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)
|
||||
try:
|
||||
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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user