From 44e9859c53cd575150bc86f229ca8dbdf4f228e6 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 22 Jan 2009 16:59:52 +0900 Subject: [PATCH] fix updateCard() index error in editor --- ankiqt/ui/cardlist.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ankiqt/ui/cardlist.py b/ankiqt/ui/cardlist.py index 7c7821f27..4ec90060b 100644 --- a/ankiqt/ui/cardlist.py +++ b/ankiqt/ui/cardlist.py @@ -150,11 +150,15 @@ class DeckModel(QAbstractTableModel): self.reset() def updateCard(self, index): - self.cards[index.row()] = self.deck.s.first(""" -select id, priority, question, answer, due, reps, factId -from cards where id = :id""", id=self.cards[index.row()][0]) - self.emit(SIGNAL("dataChanged(QModelIndex,QModelIndex)"), - index, self.index(index.row(), 1)) + try: + self.cards[index.row()] = self.deck.s.first(""" + select id, priority, question, answer, due, reps, factId + from cards where id = :id""", id=self.cards[index.row()][0]) + self.emit(SIGNAL("dataChanged(QModelIndex,QModelIndex)"), + index, self.index(index.row(), 1)) + except IndexError: + # called after search changed + pass # Tools ######################################################################