mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
avoid running timers after collection unload
fixes: - onRefreshTimer() firing when collection is in the process of unloading - saveNow() in the no changes case, which fires a timer 10ms later
This commit is contained in:
parent
080118876a
commit
b06b70f721
2 changed files with 8 additions and 4 deletions
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue