don't throw an error when closing with tooltip or debug window open

This commit is contained in:
Damien Elmes 2017-08-25 12:14:59 +10:00
parent 3b9ac82a32
commit 7b1747d650
2 changed files with 7 additions and 2 deletions

View File

@ -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)

View File

@ -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()