mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Check 'index.isValid()' in 'table.model'
This commit is contained in:
parent
09cc55b0d3
commit
2b5bf23bbd
2 changed files with 4 additions and 4 deletions
|
@ -175,6 +175,8 @@ class DataModel(QAbstractTableModel):
|
|||
|
||||
def get_card(self, index: QModelIndex) -> Optional[Card]:
|
||||
"""Try to return the indicated, possibly deleted card."""
|
||||
if not index.isValid():
|
||||
return None
|
||||
try:
|
||||
return self._state.get_card(self.get_item(index))
|
||||
except NotFoundError:
|
||||
|
@ -182,6 +184,8 @@ class DataModel(QAbstractTableModel):
|
|||
|
||||
def get_note(self, index: QModelIndex) -> Optional[Note]:
|
||||
"""Try to return the indicated, possibly deleted note."""
|
||||
if not index.isValid():
|
||||
return None
|
||||
try:
|
||||
return self._state.get_note(self.get_item(index))
|
||||
except NotFoundError:
|
||||
|
|
|
@ -78,13 +78,9 @@ class Table:
|
|||
# Get objects
|
||||
|
||||
def get_current_card(self) -> Optional[Card]:
|
||||
if not self.has_current():
|
||||
return None
|
||||
return self._model.get_card(self._current())
|
||||
|
||||
def get_current_note(self) -> Optional[Note]:
|
||||
if not self.has_current():
|
||||
return None
|
||||
return self._model.get_note(self._current())
|
||||
|
||||
def get_single_selected_card(self) -> Optional[Card]:
|
||||
|
|
Loading…
Reference in a new issue