mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -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])
|
self.onAppMsg(args[0])
|
||||||
# Load profile in a timer so we can let the window finish init and not
|
# Load profile in a timer so we can let the window finish init and not
|
||||||
# close on profile load error.
|
# close on profile load error.
|
||||||
self.progress.timer(10, self.setupProfile, False)
|
self.progress.timer(10, self.setupProfile, False, requiresCollection=False)
|
||||||
|
|
||||||
def setupUI(self):
|
def setupUI(self):
|
||||||
self.col = None
|
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):
|
def gcWindow(self, obj):
|
||||||
obj.deleteLater()
|
obj.deleteLater()
|
||||||
self.progress.timer(1000, self.doGC, False)
|
self.progress.timer(1000, self.doGC, False, requiresCollection=False)
|
||||||
|
|
||||||
def disableGC(self):
|
def disableGC(self):
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
|
@ -58,11 +58,15 @@ class ProgressManager:
|
||||||
# automatically defers until the DB is not busy, and avoids running
|
# automatically defers until the DB is not busy, and avoids running
|
||||||
# while a progress window is visible.
|
# while a progress window is visible.
|
||||||
|
|
||||||
def timer(self, ms, func, repeat):
|
def timer(self, ms, func, repeat, requiresCollection=True):
|
||||||
def handler():
|
def handler():
|
||||||
if self.inDB or self._levels:
|
if self.inDB or self._levels:
|
||||||
# retry in 100ms
|
# 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:
|
else:
|
||||||
func()
|
func()
|
||||||
t = QTimer(self.mw)
|
t = QTimer(self.mw)
|
||||||
|
|
Loading…
Reference in a new issue