Probably a race condition. `.get_row()` is not a reliable check for card
or note existence, because it returns from an outdated cache,
if the backend is currently blocked.
This commit is contained in:
RumovZ 2022-05-18 05:34:51 +02:00 committed by GitHub
parent dba12e8cb3
commit 58370d6757
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -216,11 +216,14 @@ class DataModel(QAbstractTableModel):
"""Try to return the indicated, possibly deleted card."""
if not index.isValid():
return None
# The browser code will be calling .note() on the returned card.
# This implicitly ensures both the card and its note exist.
if self.get_row(index).is_disabled:
# The browser code will be calling .note() on the returned card, but
# the note might have been be deleted while the card still exists.
try:
card = self._state.get_card(self.get_item(index))
card.note()
except NotFoundError:
return None
return self._state.get_card(self.get_item(index))
return card
def get_note(self, index: QModelIndex) -> Note | None:
"""Try to return the indicated, possibly deleted note."""