Bug #1925378: Error when trying to edit Undefined Date

This commit is contained in:
Charles Haley 2021-04-21 19:22:18 +01:00
parent 4796b030db
commit 8a02c33eb6
2 changed files with 4 additions and 0 deletions

View File

@ -247,6 +247,8 @@ class DateDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
val = now() val = now()
else: else:
val = index.data(Qt.ItemDataRole.EditRole) val = index.data(Qt.ItemDataRole.EditRole)
if is_date_undefined(val):
val = now()
editor.setDateTime(val) editor.setDateTime(val)
# }}} # }}}

View File

@ -157,6 +157,8 @@ safeyear = lambda x: min(max(x, MINYEAR), MAXYEAR)
def qt_to_dt(qdate_or_qdatetime, as_utc=True): def qt_to_dt(qdate_or_qdatetime, as_utc=True):
o = qdate_or_qdatetime o = qdate_or_qdatetime
if o is None:
return UNDEFINED_DATE
if hasattr(o, 'toUTC'): if hasattr(o, 'toUTC'):
# QDateTime # QDateTime
o = o.toUTC() o = o.toUTC()