7198: Date editor crashes on invalid date

Now it just autoconverts into MOD_TEXT and returns whatever
text was there. This fixes the crash on the master branch,
but is not the final user experience yet.
This commit is contained in:
Vassilii Khachaturov 2013-11-15 22:26:41 +02:00
parent 89a822507a
commit 98d8e64e04

View File

@ -63,7 +63,7 @@ from gi.repository import Gtk
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
from gramps.gen.lib.date import Date from gramps.gen.lib.date import Date, DateError
from gramps.gen.datehandler import displayer from gramps.gen.datehandler import displayer
from gramps.gen.const import URL_MANUAL_PAGE from gramps.gen.const import URL_MANUAL_PAGE
from ..display import display_help from ..display import display_help
@ -216,13 +216,17 @@ class EditDate(ManagedWindow):
(the_quality, the_modifier, the_calendar, the_value, (the_quality, the_modifier, the_calendar, the_value,
the_text, the_newyear) = self.build_date_from_ui() the_text, the_newyear) = self.build_date_from_ui()
self.return_date = Date(self.date) self.return_date = Date(self.date)
self.return_date.set( try:
quality=the_quality, self.return_date.set(
modifier=the_modifier, quality=the_quality,
calendar=the_calendar, modifier=the_modifier,
value=the_value, calendar=the_calendar,
text=the_text, value=the_value,
newyear=the_newyear) text=the_text,
newyear=the_newyear)
except DateError:
self.return_date.set(modifier=Date.MOD_TEXTONLY,
text=the_text)
self.close() self.close()
break break