From b0091053bf44a92debecd94cb85ff68edbbc43f3 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 12 Oct 2018 12:08:19 +1000 Subject: [PATCH] don't require collection for top toolbar This is a hack, and ideally the code would be refactored so that the entire main window is not loaded until a collection is available, but doing that will break a bunch of add-ons. Fixes https://anki.tenderapp.com/discussions/beta-testing/1276-anki-215-beta#comment_46241878 --- aqt/toolbar.py | 1 + aqt/webview.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/aqt/toolbar.py b/aqt/toolbar.py index c5600a2a4..4112ad84f 100644 --- a/aqt/toolbar.py +++ b/aqt/toolbar.py @@ -18,6 +18,7 @@ class Toolbar: "sync": self._syncLinkHandler, } self.web.setFixedHeight(30) + self.web.requiresCol = False def draw(self): self.web.onBridgeCmd = self._linkHandler diff --git a/aqt/webview.py b/aqt/webview.py index 472183f07..21ea9360a 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -91,6 +91,7 @@ class AnkiWebView(QWebEngineView): self._domDone = True self._pendingActions = [] + self.requiresCol = True self.setPage(self._page) self._page.profile().setHttpCacheType(QWebEngineProfile.NoCache) @@ -319,7 +320,11 @@ body {{ zoom: {}; {} }} # async web events may be received after the profile has been closed # or the underlying webview has been deleted from aqt import mw - return not mw.col or sip.isdeleted(self) + if sip.isdeleted(self): + return True + if not mw.col and self.requiresCol: + return True + return False def _onBridgeCmd(self, cmd): if self._shouldIgnoreWebEvent():