diff options
author | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-02-20 12:39:08 +0200 |
---|---|---|
committer | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-02-20 12:39:08 +0200 |
commit | 0cdb13d0b66a2489fe2343ce2eaa536a3eae7adb (patch) | |
tree | 28f20cce7fed95aef697be6457b552e618163f8a /src/webengine/api/qquickwebenginedownloaditem.cpp | |
parent | cfaa49a9e5ec5e01c57a5621702c881ae07ab515 (diff) | |
parent | 7537526093c92e89672d1e952a9baceecaa91730 (diff) |
Merge 5.12 into 5.12.2
Change-Id: I660e890b4630fba2c6828571cac99a529f24be50
Diffstat (limited to 'src/webengine/api/qquickwebenginedownloaditem.cpp')
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index a80f163d5..981d11633 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -185,10 +185,8 @@ void QQuickWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::Down Q_EMIT q->totalBytesChanged(); } - if (info.done != downloadFinished) { - downloadFinished = info.done; - Q_EMIT q->isFinishedChanged(); - } + if (info.done) + setFinished(); if (info.paused != downloadPaused) { downloadPaused = info.paused; @@ -206,6 +204,17 @@ void QQuickWebEngineDownloadItemPrivate::updateState(QQuickWebEngineDownloadItem } } +void QQuickWebEngineDownloadItemPrivate::setFinished() +{ + Q_Q(QQuickWebEngineDownloadItem); + + if (downloadFinished) + return; + + downloadFinished = true; + Q_EMIT q->isFinishedChanged(); +} + /*! \qmlmethod void WebEngineDownloadItem::accept() @@ -255,6 +264,7 @@ void QQuickWebEngineDownloadItem::cancel() return; d->updateState(QQuickWebEngineDownloadItem::DownloadCancelled); + d->setFinished(); // We directly cancel the download if the user cancels before // it even started, so no need to notify the profile here. @@ -593,12 +603,14 @@ bool QQuickWebEngineDownloadItem::isPaused() const } /*! - \qmlproperty bool WebEngineDownloadItem::view + \qmlproperty WebEngineView WebEngineDownloadItem::view \readonly \since QtWebEngine 1.8 Returns the view the download was requested on. If the download was not triggered by content in a view, \c nullptr is returned. + + \sa WebEngineView */ QQuickWebEngineView *QQuickWebEngineDownloadItem::view() const { @@ -615,8 +627,8 @@ QQuickWebEngineDownloadItem::QQuickWebEngineDownloadItem(QQuickWebEngineDownload QQuickWebEngineDownloadItem::~QQuickWebEngineDownloadItem() { - if (d_ptr->profile) - d_ptr->profile->d_ptr->profileAdapter()->removeDownload(d_ptr->downloadId); + if (!isFinished()) + cancel(); } QT_END_NAMESPACE |