Skip to content

Commit

Permalink
run the gc only in the main thread
Browse files Browse the repository at this point in the history
if it fires in the mediasrv/sync thread it could cause a crash
  • Loading branch information
dae committed Jan 8, 2017
1 parent 9f28d5a commit 147e09a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions aqt/main.py
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 147e09a

Please sign in to comment.