From 2ad0c1e8c134a8d4f60593b7747450bba8319bb0 Mon Sep 17 00:00:00 2001 From: Andras Becsi Date: Mon, 2 Feb 2015 16:41:04 +0100 Subject: Fix widgets download state update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the DownloadState enum of core does not match the DownloadState enum of QWebEngineDownloadItem we should never directly compare it, instead we should convert with the toDownloadState() function, to fix the missing emission of the finished() signal. This patch also adds static asserts to verify the match of chromium's DownloadItem::DownloadState and our core DownloadState. Change-Id: I51110f55598230e380e15948f75219976d3a68a0 Reviewed-by: Michael BrĂ¼ning --- src/core/download_manager_delegate_qt.cpp | 5 +++++ src/webenginewidgets/api/qwebenginedownloaditem.cpp | 2 +- src/webenginewidgets/api/qwebengineprofile.cpp | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index c46bfb080..78d5f909a 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -53,6 +53,11 @@ #include "type_conversion.h" #include "qtwebenginecoreglobal.h" +ASSERT_ENUMS_MATCH(content::DownloadItem::IN_PROGRESS, BrowserContextAdapterClient::DownloadInProgress) +ASSERT_ENUMS_MATCH(content::DownloadItem::COMPLETE, BrowserContextAdapterClient::DownloadCompleted) +ASSERT_ENUMS_MATCH(content::DownloadItem::CANCELLED, BrowserContextAdapterClient::DownloadCancelled) +ASSERT_ENUMS_MATCH(content::DownloadItem::INTERRUPTED, BrowserContextAdapterClient::DownloadInterrupted) + DownloadManagerDelegateQt::DownloadManagerDelegateQt(BrowserContextAdapter *contextAdapter) : m_contextAdapter(contextAdapter) , m_currentId(0) diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index f97b25431..9bfe1f9fd 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -91,7 +91,7 @@ void QWebEngineDownloadItemPrivate::update(const BrowserContextAdapterClient::Do Q_ASSERT(downloadState != QWebEngineDownloadItem::DownloadRequested); - if (info.state != downloadState) { + if (toDownloadState(info.state) != downloadState) { downloadState = toDownloadState(info.state); Q_EMIT q->stateChanged(downloadState); } diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index eceee0fd3..8c4dcb59f 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -91,6 +91,7 @@ QT_BEGIN_NAMESPACE cancelled by default. The download item is parented by the profile, but if not accepted will be deleted immediately after the signal emission. + This signal can not be used with a queued connection. \sa QWebEngineDownloadItem */ -- cgit v1.2.3