From 9e9d8b9c7acab31e8440396ac00207a14b8449b0 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Sat, 30 Jan 2021 13:15:46 +0100 Subject: [PATCH] Build list in focusCid and specify exception model.cards may be a protobuf sequence but focusCid needs list's index method, so convert to list, but only if needed. --- qt/aqt/browser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qt/aqt/browser.py b/qt/aqt/browser.py index 7f32d2fd8..414336539 100644 --- a/qt/aqt/browser.py +++ b/qt/aqt/browser.py @@ -190,7 +190,7 @@ class DataModel(QAbstractTableModel): ctx = SearchContext(search=txt, browser=self.browser) gui_hooks.browser_will_search(ctx) if ctx.card_ids is None: - ctx.card_ids = list(self.col.find_cards(ctx.search, order=ctx.order)) + ctx.card_ids = self.col.find_cards(ctx.search, order=ctx.order) gui_hooks.browser_did_search(ctx) self.cards = ctx.card_ids except Exception as err: @@ -1829,8 +1829,8 @@ where id in %s""" def focusCid(self, cid): try: - row = self.model.cards.index(cid) - except: + row = list(self.model.cards).index(cid) + except ValueError: return self.form.tableView.clearSelection() self.form.tableView.selectRow(row)