diff --git a/aqt/main.py b/aqt/main.py index 8498b9710..bfac0e9f6 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -62,7 +62,7 @@ class AnkiQt(QMainWindow): self.onAppMsg(args[0]) # Load profile in a timer so we can let the window finish init and not # close on profile load error. - self.progress.timer(10, self.setupProfile, False) + self.progress.timer(10, self.setupProfile, False, requiresCollection=False) def setupUI(self): self.col = None @@ -1311,7 +1311,7 @@ Please ensure a profile is open and Anki is not busy, then try again."""), def gcWindow(self, obj): obj.deleteLater() - self.progress.timer(1000, self.doGC, False) + self.progress.timer(1000, self.doGC, False, requiresCollection=False) def disableGC(self): gc.collect() diff --git a/aqt/progress.py b/aqt/progress.py index 4e15f92ec..7c5b46410 100644 --- a/aqt/progress.py +++ b/aqt/progress.py @@ -58,11 +58,15 @@ class ProgressManager: # automatically defers until the DB is not busy, and avoids running # while a progress window is visible. - def timer(self, ms, func, repeat): + def timer(self, ms, func, repeat, requiresCollection=True): def handler(): if self.inDB or self._levels: # retry in 100ms - self.timer(100, func, False) + self.timer(100, func, False, requiresCollection) + elif not self.mw.col and requiresCollection: + # ignore timer events that fire after collection has been + # unloaded + print("Ignored progress func as collection unloaded: %s" % repr(func)) else: func() t = QTimer(self.mw)