mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
run the gc only in the main thread
if it fires in the mediasrv/sync thread it could cause a crash
This commit is contained in:
parent
9f28d5a638
commit
147e09a6cb
1 changed files with 11 additions and 8 deletions
19
aqt/main.py
19
aqt/main.py
|
@ -68,6 +68,7 @@ class AnkiQt(QMainWindow):
|
||||||
def setupUI(self):
|
def setupUI(self):
|
||||||
self.col = None
|
self.col = None
|
||||||
self.setupCrashLog()
|
self.setupCrashLog()
|
||||||
|
self.setupGC()
|
||||||
self.setupAppMsg()
|
self.setupAppMsg()
|
||||||
self.setupKeys()
|
self.setupKeys()
|
||||||
self.setupThreads()
|
self.setupThreads()
|
||||||
|
@ -1150,21 +1151,23 @@ Please ensure a profile is open and Anki is not busy, then try again."""),
|
||||||
|
|
||||||
# GC
|
# GC
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# run the garbage collector after object is deleted so we don't leave
|
# ensure gc runs in main thread
|
||||||
# expensive web engine processes lying around
|
|
||||||
|
|
||||||
def setupDialogGC(self, obj):
|
def setupDialogGC(self, obj):
|
||||||
obj.finished.connect(lambda o=obj: self.gcWindow(obj))
|
obj.finished.connect(lambda o=obj: self.gcWindow(obj))
|
||||||
|
|
||||||
def gcWindow(self, obj):
|
def gcWindow(self, obj):
|
||||||
obj.deleteLater()
|
obj.deleteLater()
|
||||||
t = QTimer(self)
|
|
||||||
t.timeout.connect(self._onCollect)
|
|
||||||
t.setSingleShot(True)
|
|
||||||
# will run next time queue is idle
|
|
||||||
t.start(0)
|
|
||||||
|
|
||||||
def _onCollect(self):
|
def setupGC(self):
|
||||||
|
gc.collect()
|
||||||
|
gc.disable()
|
||||||
|
#gc.set_debug(gc.DEBUG_SAVEALL)
|
||||||
|
self.gcTimer = QTimer(self)
|
||||||
|
self.gcTimer.timeout.connect(self.runGC)
|
||||||
|
self.gcTimer.start(60*1000)
|
||||||
|
|
||||||
|
def runGC(self):
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
# Crash log
|
# Crash log
|
||||||
|
|
Loading…
Reference in a new issue