Fixes #1925378 [Error when trying to edit Undefined Date](https://bugs.launchpad.net/calibre/+bug/1925378)
This commit is contained in:
Kovid Goyal 2021-04-22 07:54:48 +05:30
commit 5d9e2296f3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
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()