mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
fix error on add-on download
suspect this was the cause of the mystery enclosing scope errors as well
This commit is contained in:
parent
02a3e14c13
commit
92fe869653
1 changed files with 8 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue