From ebc70f66e5e4b671ee6b4d975339e253a0a1ea2c Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Tue, 21 Mar 2017 18:54:21 +0100 Subject: [PATCH] Check for None-reply in _do_die Fixes #2304 In some cases, the finished handler fired before the error handler, e.g. when downloading a 500 error page that is sent as attachment: HTTP/1.1 500 Internal Server Error Content-Type: application/octet-stream Content-Disposition: inline; filename="attachment.jpg" here we downloaded 0 bytes, fired the finished handler and after that fired the error handler because of the 500 - but the finished handler had already set our reply to None (and displayed the error message). --- qutebrowser/browser/qtnetworkdownloads.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qutebrowser/browser/qtnetworkdownloads.py b/qutebrowser/browser/qtnetworkdownloads.py index 5ac689e29..920673d4b 100644 --- a/qutebrowser/browser/qtnetworkdownloads.py +++ b/qutebrowser/browser/qtnetworkdownloads.py @@ -110,6 +110,9 @@ class DownloadItem(downloads.AbstractDownloadItem): def _do_die(self): """Abort the download and emit an error.""" self._read_timer.stop() + if self._reply is None: + log.downloads.debug("Reply gone while dying") + return self._reply.downloadProgress.disconnect() self._reply.finished.disconnect() self._reply.error.disconnect()