From 92fe8696530285a61fa188a4591d65c92c0fd412 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 26 Aug 2017 19:55:39 +1000 Subject: [PATCH] fix error on add-on download suspect this was the cause of the mystery enclosing scope errors as well --- aqt/downloader.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/aqt/downloader.py b/aqt/downloader.py index a88c55601..517c1878b 100644 --- a/aqt/downloader.py +++ b/aqt/downloader.py @@ -13,20 +13,20 @@ def download(mw, code): "Download addon from AnkiWeb. Caller must start & stop progress diag." # create downloading thread thread = Downloader(code) + done = False def onRecv(): - try: - mw.progress.update(label="%dKB downloaded" % (thread.recvTotal/1024)) - except NameError: - # some users report the following error on long downloads - # NameError: free variable 'mw' referenced before assignment in enclosing scope - # unsure why this is happening, but guard against throwing the - # error - pass + if done: + return + mw.progress.update(label="%dKB downloaded" % (thread.recvTotal/1024)) thread.recv.connect(onRecv) thread.start() while not thread.isFinished(): mw.app.processEvents() thread.wait(100) + + # make sure any posted events don't fire after we return + done = True + if not thread.error: # success return thread.data, thread.fname