diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-16 13:09:44 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-16 17:01:24 +0100 |
commit | 819e00f71e37f5230b9b2c2ff756db4cc4cfda5e (patch) | |
tree | ed8f247651f06581c462c6cbefde4fa097000946 /src/webenginewidgets | |
parent | 9ed734bfdd7b70f4f7f8e78529ead40031607f99 (diff) | |
parent | 2620f6baa55dc13d65ea0d4b09a23ddfae580279 (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
src/3rdparty
src/core/web_contents_adapter.cpp
src/webengine/api/qquickwebengineprofile.cpp
src/webenginewidgets/api/qwebengineprofile.cpp
tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
Change-Id: I56c093ebab5ee8b577783ce71761719159cd3ddd
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem.cpp | 7 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 29 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile_p.h | 18 |
3 files changed, 9 insertions, 45 deletions
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index a5569e408..dc1a48360 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -195,9 +195,10 @@ void QWebEngineDownloadItem::cancel() // We directly cancel the download request if the user cancels // before it even started, so no need to notify the profile here. - if (state == QWebEngineDownloadItem::DownloadInProgress) - d->profile->browserContext()->cancelDownload(d->downloadId); - else { + if (state == QWebEngineDownloadItem::DownloadInProgress) { + if (auto browserContext = d->profile->browserContext()) + browserContext->cancelDownload(d->downloadId); + } else { d->downloadState = QWebEngineDownloadItem::DownloadCancelled; Q_EMIT stateChanged(d->downloadState); } diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 5a6c0e18a..2897d9798 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -47,8 +47,9 @@ #include "qwebenginesettings.h" #include "qwebenginescriptcollection_p.h" +#include "qwebenginebrowsercontext_p.h" +#include "qtwebenginecoreglobal.h" #include "browser_context_adapter.h" -#include <qtwebenginecoreglobal.h> #include "visited_links_manager_qt.h" #include "web_engine_settings.h" @@ -145,30 +146,6 @@ using QtWebEngineCore::BrowserContextAdapter; \sa QWebEngineDownloadItem, QWebEnginePage::download() */ -QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QWebEngineProfilePrivate *profile) - : QObject(BrowserContextAdapter::globalQObjectRoot()) - , browserContextRef(browserContext) - , m_profile(profile) -{ - browserContextRef->addClient(m_profile); -} - -QWebEngineBrowserContext::~QWebEngineBrowserContext() -{ - if (m_profile) - shutdown(); -} - -void QWebEngineBrowserContext::shutdown() -{ - Q_ASSERT(m_profile); - // In the case the user sets this profile as the parent of the interceptor - // it can be deleted before the browser-context still referencing it is. - browserContextRef->setRequestInterceptor(nullptr); - browserContextRef->removeClient(m_profile); - m_profile = 0; -} - QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext) : m_settings(new QWebEngineSettings()) , m_scriptCollection(new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userResourceController()))) @@ -194,7 +171,7 @@ QWebEngineProfilePrivate::~QWebEngineProfilePrivate() QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QWebEngineProfilePrivate::browserContext() const { - return m_browserContext->browserContextRef; + return m_browserContext ? m_browserContext->browserContextRef : nullptr; } void QWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index 07aad9176..8d9e5011f 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -54,6 +54,7 @@ #include "browser_context_adapter_client.h" #include "qwebengineprofile.h" #include "qwebenginescriptcollection.h" + #include <QMap> #include <QPointer> #include <QScopedPointer> @@ -65,25 +66,10 @@ class BrowserContextAdapter; QT_BEGIN_NAMESPACE +class QWebEngineBrowserContext; class QWebEngineProfilePrivate; class QWebEngineSettings; -// This is a wrapper class for BrowserContextAdapter. BrowserContextAdapter must be destructed before WebEngineContext -// is destructed. Therefore access it via the QWebEngineBrowserContext which parent is the WebEngineContext::globalQObject. -// This guarantees the destruction together with the WebEngineContext. -class QWebEngineBrowserContext : public QObject { -public: - QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QWebEngineProfilePrivate *profile); - ~QWebEngineBrowserContext(); - - void shutdown(); - - QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextRef; - -private: - QWebEngineProfilePrivate *m_profile; -}; - class QWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QWebEngineProfile) |