From 147e09a6cb4d4e385fe142c7e4db84dba970b185 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 8 Jan 2017 14:42:50 +1000 Subject: [PATCH] run the gc only in the main thread if it fires in the mediasrv/sync thread it could cause a crash --- aqt/main.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/aqt/main.py b/aqt/main.py index 782b79212b..67e231280b 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -68,6 +68,7 @@ def __init__(self, app, profileManager, args): def setupUI(self): self.col = None self.setupCrashLog() + self.setupGC() self.setupAppMsg() self.setupKeys() self.setupThreads() @@ -1150,21 +1151,23 @@ def onAppMsg(self, buf): # GC ########################################################################## - # run the garbage collector after object is deleted so we don't leave - # expensive web engine processes lying around + # ensure gc runs in main thread def setupDialogGC(self, obj): obj.finished.connect(lambda o=obj: self.gcWindow(obj)) def gcWindow(self, obj): 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() # Crash log