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() self.maybeAutoSync()
def _checkForUnclosedWidgets(self): def _checkForUnclosedWidgets(self):
for w in self.app.topLevelWidgets(): for w in self.app.topLevelWidgets():
if w.isVisible(): 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): def unloadProfileAndExit(self):
self.unloadProfile(self.cleanupAndExit) self.unloadProfile(self.cleanupAndExit)
@ -1065,6 +1068,7 @@ will be lost. Continue?"""))
def onDebug(self): def onDebug(self):
d = self.debugDiag = QDialog() d = self.debugDiag = QDialog()
d.silentlyClose = True
frm = aqt.forms.debug.Ui_Dialog() frm = aqt.forms.debug.Ui_Dialog()
frm.setupUi(d) frm.setupUi(d)
s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+return"), d) s = self.debugDiagShort = QShortcut(QKeySequence("ctrl+return"), d)

View File

@ -392,6 +392,7 @@ _tooltipLabel = None
def tooltip(msg, period=3000, parent=None): def tooltip(msg, period=3000, parent=None):
global _tooltipTimer, _tooltipLabel global _tooltipTimer, _tooltipLabel
class CustomLabel(QLabel): class CustomLabel(QLabel):
silentlyClose = True
def mousePressEvent(self, evt): def mousePressEvent(self, evt):
evt.accept() evt.accept()
self.hide() self.hide()