Fix retrying downloads with QtWebEngine

Fixes #2298
This commit is contained in:
Florian Bruhin 2017-03-20 09:32:44 +01:00
parent 1581db2d59
commit 3e2ba32240
5 changed files with 21 additions and 3 deletions

View File

@ -34,6 +34,7 @@ Fixed
- Added a workaround for a black screen with QtWebEngine with some setups
(requires PyOpenGL to be installed)
- Fixed crash when trying to retry downloads with QtWebEngine
v0.10.1
-------

View File

@ -507,6 +507,14 @@ class AbstractDownloadItem(QObject):
"""Retry a failed download."""
raise NotImplementedError
@pyqtSlot()
def try_retry(self):
"""Try to retry a download and show an error if it's unsupported."""
try:
self.retry()
except UnsupportedOperationError as e:
message.error(str(e))
def _get_open_filename(self):
"""Get the filename to open a download.
@ -968,7 +976,7 @@ class DownloadModel(QAbstractListModel):
raise cmdexc.CommandError("No failed downloads!")
else:
download = to_retry[0]
download.retry()
download.try_retry()
def can_clear(self):
"""Check if there are finished downloads to clear."""

View File

@ -134,7 +134,7 @@ class DownloadView(QListView):
if item.successful:
actions.append(("Open", item.open_file))
else:
actions.append(("Retry", item.retry))
actions.append(("Retry", item.try_retry))
actions.append(("Remove", item.remove))
else:
actions.append(("Cancel", item.cancel))

View File

@ -95,7 +95,8 @@ class DownloadItem(downloads.AbstractDownloadItem):
def retry(self):
# https://bugreports.qt.io/browse/QTBUG-56840
raise downloads.UnsupportedOperationError
raise downloads.UnsupportedOperationError(
"Retrying downloads is unsupported with QtWebEngine")
def _get_open_filename(self):
return self._filename

View File

@ -137,6 +137,14 @@ Feature: Downloading things from a website.
does-not-exist
does-not-exist
@qtwebkit_skip
Scenario: Retrying a failed download with QtWebEngine
When I open data/downloads/issue2298.html
And I run :click-element id download
And I wait for "Download error: *" in the log
And I run :download-retry
Then the error "Retrying downloads is unsupported with QtWebEngine" should be shown
Scenario: Retrying with count
When I run :download http://localhost:(port)/data/downloads/download.bin
And I run :download http://localhost:(port)/does-not-exist