summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-05-05 17:28:19 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2017-05-08 18:07:25 +0000
commit757d5b1cea0d3d70b97b31f331df9ada82f45d2d (patch)
tree731388cd64fd0ec8e24446ed0ff3cb8fe3d7fdac
parentb5c5f12588a20e88b472d32b0532f6129930f02c (diff)
Fix crash on exit with url-request interceptors
If the interceptor is the child of the profile, they will be deleted with the API profile which is before the underlying browser-context, they should therefore be unset from the browser context first. Task-number: QTBUG-60236 Change-Id: I2954e8106863b8b421ef166f6bf8fa79240c95ee Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/core/browser_context_adapter.cpp2
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp2
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp4
3 files changed, 8 insertions, 0 deletions
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index 1da186584..bec76ad81 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -162,6 +162,8 @@ QWebEngineUrlRequestInterceptor *BrowserContextAdapter::requestInterceptor()
void BrowserContextAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
{
+ if (m_requestInterceptor == interceptor)
+ return;
m_requestInterceptor = interceptor;
if (m_browserContext->url_request_getter_.get())
m_browserContext->url_request_getter_->updateRequestInterceptor();
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index f22ec86a4..260d8958b 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -153,6 +153,8 @@ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer<Brow
QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate()
{
+ m_browserContextRef->setRequestInterceptor(nullptr);
+
m_browserContextRef->removeClient(this);
Q_FOREACH (QQuickWebEngineDownloadItem* download, m_ongoingDownloads) {
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index abed066d3..cd4fc8b02 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -156,6 +156,10 @@ QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<BrowserContext
QWebEngineProfilePrivate::~QWebEngineProfilePrivate()
{
+ // 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.
+ m_browserContextRef->setRequestInterceptor(nullptr);
+
delete m_settings;
m_settings = 0;
m_browserContextRef->removeClient(this);