Fix #2132137 ['NoneType' object has no attribute 'underlying_book_id'](https://bugs.launchpad.net/calibre/+bug/2132137)

This commit is contained in:
Kovid Goyal 2025-11-22 08:49:58 +05:30
parent 96e3c3458c
commit 9b81dd7090
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -209,7 +209,7 @@ class StyledItemDelegate(QStyledItemDelegate):
def createEditor(self, parent, option, index):
e = self.create_editor(parent, option, index)
if (book_id := index.data(Qt.ItemDataRole.UserRole)) and isinstance(book_id, int):
if e is not None and (book_id := index.data(Qt.ItemDataRole.UserRole)) and isinstance(book_id, int):
setattr(e, 'underlying_book_id', book_id)
return e