From 7b1747d6504c9091a34793cebaa559b9fb6968df Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 25 Aug 2017 12:14:59 +1000 Subject: [PATCH] don't throw an error when closing with tooltip or debug window open --- aqt/main.py | 8 ++++++-- aqt/utils.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/aqt/main.py b/aqt/main.py index b91d2f9f6..1b1cd3eeb 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -276,11 +276,14 @@ close the profile or restart Anki.""")) self.maybeAutoSync() - def _checkForUnclosedWidgets(self): for w in self.app.topLevelWidgets(): if w.isVisible(): - showWarning(f"Window should have been closed: {w}") + # windows with this property are safe to close immediately + if getattr(w, "silentlyClose"): + w.close() + else: + showWarning(f"Window should have been closed: {w}") def unloadProfileAndExit(self): self.unloadProfile(self.cleanupAndExit) @@ -1065,6 +1068,7 @@ will be lost. Continue?""")) def onDebug(self): d = self.debugDiag = QDialog() + d.silentlyClose = True frm = aqt.forms.debug.Ui_Dialog() frm.setupUi(d) s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+return"), d) diff --git a/aqt/utils.py b/aqt/utils.py index f5a150697..85bb21f95 100644 --- a/aqt/utils.py +++ b/aqt/utils.py @@ -392,6 +392,7 @@ _tooltipLabel = None def tooltip(msg, period=3000, parent=None): global _tooltipTimer, _tooltipLabel class CustomLabel(QLabel): + silentlyClose = True def mousePressEvent(self, evt): evt.accept() self.hide()