diff options
author | Daniel Schadt <kingdread@gmx.de> | 2016-08-02 01:10:40 +0200 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2016-08-02 16:17:05 +0200 |
commit | 6ac394026423a8c9c6168c303f48833f8460565c (patch) | |
tree | a21749474ec80b7f38cf3611539bae787d87f034 | |
parent | 5e9eafd5a3cb6f409658825f560463ed63b3c66c (diff) | |
download | qutebrowser-6ac394026423a8c9c6168c303f48833f8460565c.tar.gz qutebrowser-6ac394026423a8c9c6168c303f48833f8460565c.zip |
open-download: don't crash on download cancel
Fixes #1728.
-rw-r--r-- | qutebrowser/browser/webkit/downloads.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/qutebrowser/browser/webkit/downloads.py b/qutebrowser/browser/webkit/downloads.py index 47d264d37..723edebb8 100644 --- a/qutebrowser/browser/webkit/downloads.py +++ b/qutebrowser/browser/webkit/downloads.py @@ -954,12 +954,21 @@ class DownloadManager(QAbstractListModel): message.error(self._win_id, msg) download.cancel() return - download.finished.connect(download.open_file) + download.finished.connect( + functools.partial(self._open_download, download)) download.autoclose = True download.set_fileobj(fobj) else: log.downloads.error("Unknown download target: {}".format(target)) + def _open_download(self, download): + """Open the given download but only if it was successful.""" + if download.successful: + download.open_file() + else: + log.downloads.debug("{} finished but not successful, not opening!" + .format(download)) + def raise_no_download(self, count): """Raise an exception that the download doesn't exist. |