mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -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."
|
"Download addon from AnkiWeb. Caller must start & stop progress diag."
|
||||||
# create downloading thread
|
# create downloading thread
|
||||||
thread = Downloader(code)
|
thread = Downloader(code)
|
||||||
|
done = False
|
||||||
def onRecv():
|
def onRecv():
|
||||||
try:
|
if done:
|
||||||
|
return
|
||||||
mw.progress.update(label="%dKB downloaded" % (thread.recvTotal/1024))
|
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
|
|
||||||
thread.recv.connect(onRecv)
|
thread.recv.connect(onRecv)
|
||||||
thread.start()
|
thread.start()
|
||||||
while not thread.isFinished():
|
while not thread.isFinished():
|
||||||
mw.app.processEvents()
|
mw.app.processEvents()
|
||||||
thread.wait(100)
|
thread.wait(100)
|
||||||
|
|
||||||
|
# make sure any posted events don't fire after we return
|
||||||
|
done = True
|
||||||
|
|
||||||
if not thread.error:
|
if not thread.error:
|
||||||
# success
|
# success
|
||||||
return thread.data, thread.fname
|
return thread.data, thread.fname
|
||||||
|
|
Loading…
Reference in a new issue