From 4884d0edf792250969f328035b5b9d31a3539c2f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 9 May 2013 15:34:16 +0900 Subject: [PATCH] handle chrome's newlines in url issue and make sure to clean up progress --- aqt/editor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aqt/editor.py b/aqt/editor.py index 8df6cb4a3..1d0c413b5 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -1022,6 +1022,8 @@ class EditorWebView(AnkiWebView): def _processUrls(self, mime): url = mime.urls()[0].toString() + # chrome likes to give us the URL twice with a \n + url = url.splitlines()[0] link = self._localizedMediaLink(url) mime = QMimeData() mime.setHtml(link) @@ -1093,11 +1095,12 @@ class EditorWebView(AnkiWebView): except urllib2.URLError, e: showWarning(self.errtxt % e) return + finally: + self.editor.mw.progress.finish() path = namedtmp(os.path.basename(urllib2.unquote(url))) file = open(path, "wb") file.write(filecontents) file.close() - self.editor.mw.progress.finish() return self.editor._addMedia(path) def _flagAnkiText(self):