Fix crashes with downloads in a closed tab.

When a download was redirected or failed after a tab was closed, there was a
KeyError in the object registry.

Fixes #889. This is a regression introduced in
976f758da1 / #731.
This commit is contained in:
Florian Bruhin 2015-11-09 07:46:22 +01:00
parent 89c0ff0d9b
commit b59a56921e

View File

@ -363,9 +363,14 @@ class NetworkManager(QNetworkAccessManager):
if self._tab_id is None:
current_url = QUrl() # generic NetworkManager, e.g. for downloads
else:
webview = objreg.get('webview', scope='tab', window=self._win_id,
tab=self._tab_id)
current_url = webview.url()
try:
webview = objreg.get('webview', scope='tab',
window=self._win_id, tab=self._tab_id)
except KeyError:
# https://github.com/The-Compiler/qutebrowser/issues/889
current_url = QUrl()
else:
current_url = webview.url()
self.set_referer(req, current_url)