From 3584a8f0048d13ffb31f5635608a7593217348e9 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 1 Mar 2013 14:53:00 +0900 Subject: [PATCH] fix "free variable 'mw'" error (#284) --- aqt/downloader.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/aqt/downloader.py b/aqt/downloader.py index b0437bed7..e8ebb211d 100644 --- a/aqt/downloader.py +++ b/aqt/downloader.py @@ -20,7 +20,14 @@ def download(mw, code): # create downloading thread thread = Downloader(code) def onRecv(): - mw.progress.update(label="%dKB downloaded" % (thread.recvTotal/1024)) + 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 mw.connect(thread, SIGNAL("recv"), onRecv) thread.start() mw.progress.start(immediate=True)