7360: Calendar conversion broken in date editor
1) using a new field self.validated_date instead of self.date that collided with the switch_calendar callback 2) provide for the Date.set failure possibility in switch_calendar, and do no field conversion if it throws, just switch the calendar (thanks to Nick for finding)
This commit is contained in:
parent
8bc6336e27
commit
ecdccaf351
@ -276,7 +276,7 @@ class DateEditorDialog(ManagedWindow.ManagedWindow):
|
|||||||
# want to have several open dialogs, since then the user will
|
# want to have several open dialogs, since then the user will
|
||||||
# loose track of which is which. Much like opening files.
|
# loose track of which is which. Much like opening files.
|
||||||
|
|
||||||
self.return_date = None
|
self.validated_date = self.return_date = None
|
||||||
|
|
||||||
for o in self.top.get_objects():
|
for o in self.top.get_objects():
|
||||||
try:
|
try:
|
||||||
@ -303,7 +303,7 @@ class DateEditorDialog(ManagedWindow.ManagedWindow):
|
|||||||
if not self.revalidate():
|
if not self.revalidate():
|
||||||
continue
|
continue
|
||||||
self.return_date = Date()
|
self.return_date = Date()
|
||||||
self.return_date.copy(self.date)
|
self.return_date.copy(self.validated_date)
|
||||||
self.close()
|
self.close()
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -327,8 +327,9 @@ class DateEditorDialog(ManagedWindow.ManagedWindow):
|
|||||||
value=the_value,
|
value=the_value,
|
||||||
text=the_text,
|
text=the_text,
|
||||||
newyear=the_newyear)
|
newyear=the_newyear)
|
||||||
self.date.copy(d)
|
# didn't throw yet?
|
||||||
LOG.debug("return_date set to: {0}".format(d.dateval))
|
self.validated_date = d
|
||||||
|
LOG.debug("validated_date set to: {0}".format(d.dateval))
|
||||||
self.ok_button.set_sensitive(1)
|
self.ok_button.set_sensitive(1)
|
||||||
return True
|
return True
|
||||||
except DateError as e:
|
except DateError as e:
|
||||||
@ -435,19 +436,24 @@ class DateEditorDialog(ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
old_cal = self.date.get_calendar()
|
old_cal = self.date.get_calendar()
|
||||||
new_cal = self.calendar_box.get_active()
|
new_cal = self.calendar_box.get_active()
|
||||||
|
LOG.debug(">>>switch_calendar: {0} changed, {1} -> {2}".format(
|
||||||
|
obj, old_cal, new_cal))
|
||||||
|
|
||||||
(the_quality, the_modifier, the_calendar,
|
(the_quality, the_modifier, the_calendar,
|
||||||
the_value, the_text, the_newyear) = self.build_date_from_ui()
|
the_value, the_text, the_newyear) = self.build_date_from_ui()
|
||||||
self.date.set(
|
try:
|
||||||
quality=the_quality,
|
self.date.set(
|
||||||
modifier=the_modifier,
|
quality=the_quality,
|
||||||
calendar=old_cal,
|
modifier=the_modifier,
|
||||||
value=the_value,
|
calendar=old_cal,
|
||||||
text=the_text,
|
value=the_value,
|
||||||
newyear=the_newyear)
|
text=the_text,
|
||||||
|
newyear=the_newyear)
|
||||||
if not self.date.is_empty():
|
except DateError:
|
||||||
self.date.convert_calendar(new_cal)
|
pass
|
||||||
|
else:
|
||||||
|
if not self.date.is_empty():
|
||||||
|
self.date.convert_calendar(new_cal)
|
||||||
|
|
||||||
self.start_month_box.get_model().clear()
|
self.start_month_box.get_model().clear()
|
||||||
self.stop_month_box.get_model().clear()
|
self.stop_month_box.get_model().clear()
|
||||||
@ -462,3 +468,5 @@ class DateEditorDialog(ManagedWindow.ManagedWindow):
|
|||||||
self.stop_day.set_value(self.date.get_stop_day())
|
self.stop_day.set_value(self.date.get_stop_day())
|
||||||
self.stop_month_box.set_active(self.date.get_stop_month())
|
self.stop_month_box.set_active(self.date.get_stop_month())
|
||||||
self.stop_year.set_value(self.date.get_stop_year())
|
self.stop_year.set_value(self.date.get_stop_year())
|
||||||
|
LOG.debug("<<<switch_calendar: {0} changed, {1} -> {2}".format(
|
||||||
|
obj, old_cal, new_cal))
|
||||||
|
Loading…
Reference in New Issue
Block a user