From e366b86af23ded04f415f0497aaf0792926e56bb Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Tue, 2 Jun 2020 08:48:51 +0900 Subject: [PATCH] Handle None from QApplication.desktop().screen() This prevents a crash when Anki is open for multiple days. Reference: https://anki.tenderapp.com/discussions/ankidesktop/41879-qt-cannot-create-window-no-screens-available --- CONTRIBUTORS | 1 + qt/aqt/webview.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index bf5966b31..749d2ce59 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -37,6 +37,7 @@ Henrik Giesel MichaƂ Bartoszkiewicz Sander Santema Thomas Brownback +Andrew Gaul ******************** diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index df8da3db3..bef02d634 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -302,6 +302,9 @@ class AnkiWebView(QWebEngineView): if isMac: return 1 screen = QApplication.desktop().screen() + if screen is None: + return 1 + dpi = screen.logicalDpiX() factor = dpi / 96.0 if isLin: