From 620db695445e79cde235c58f0a60497540ea1e5b Mon Sep 17 00:00:00 2001 From: David Bailey Date: Mon, 9 Jan 2017 10:55:30 +0000 Subject: [PATCH] Fix bug caused when deleting a card just added and clicking History --- aqt/addcards.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/aqt/addcards.py b/aqt/addcards.py index a069c0696..d5f4c1775 100644 --- a/aqt/addcards.py +++ b/aqt/addcards.py @@ -142,10 +142,14 @@ class AddCards(QDialog): def onHistory(self): m = QMenu(self) for nid in self.history: - fields = self.mw.col.getNote(nid).fields - txt = stripHTMLMedia(",".join(fields))[:30] - a = m.addAction(_("Edit %s") % txt) - a.triggered.connect(lambda b, nid=nid: self.editHistory(nid)) + if self.mw.col.findNotes("nid:%s" % nid): + fields = self.mw.col.getNote(nid).fields + txt = stripHTMLMedia(",".join(fields))[:30] + a = m.addAction(_("Edit %s") % txt) + a.triggered.connect(lambda b, nid=nid: self.editHistory(nid)) + else: + a = m.addAction(_("(Note deleted)")) + a.setEnabled(False) runHook("AddCards.onHistory", self, m) m.exec_(self.historyButton.mapToGlobal(QPoint(0,0)))