summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2018-02-06 14:57:15 +0100
committerJüri Valdmann <juri.valdmann@qt.io>2018-02-13 08:18:19 +0000
commit7d6c9224ee85e01e33c30f6b4c6164f90bfdb952 (patch)
tree4b5b3c32f9b407f9f4d1da25ff75c6aa79ba6bea
parent99b084d04b9365d458d6225758224dfab26dea87 (diff)
Fix AssertBrowserContextWasntDestroyed DCHECK
Triggered sometimes in tst_qwebenginedownloads if the memory allocator reuses memory for a BrowserContextQt. Change-Id: Idb2db94cf0a8419dc45c25620708f3f3da8f9ec8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/browser_context_adapter.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index a86c66cc5..7e9a4e41d 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -85,6 +85,13 @@ BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord)
, m_httpCacheMaxSize(0)
{
WebEngineContext::current(); // Ensure the WebEngineContext has been initialized
+
+ // Mark the context as live. This prevents the use-after-free DCHECK in
+ // AssertBrowserContextWasntDestroyed from being triggered when a new
+ // BrowserContextQt object is allocated at the same address as a previously
+ // destroyed one. Needs to be called after WebEngineContext initialization.
+ BrowserContextDependencyManager::GetInstance()->MarkBrowserContextLive(m_browserContext.data());
+
content::BrowserContext::Initialize(m_browserContext.data(), toFilePath(dataPath()));
}
@@ -98,6 +105,13 @@ BrowserContextAdapter::BrowserContextAdapter(const QString &storageName)
, m_httpCacheMaxSize(0)
{
WebEngineContext::current(); // Ensure the WebEngineContext has been initialized
+
+ // Mark the context as live. This prevents the use-after-free DCHECK in
+ // AssertBrowserContextWasntDestroyed from being triggered when a new
+ // BrowserContextQt object is allocated at the same address as a previously
+ // destroyed one. Needs to be called after WebEngineContext initialization.
+ BrowserContextDependencyManager::GetInstance()->MarkBrowserContextLive(m_browserContext.data());
+
content::BrowserContext::Initialize(m_browserContext.data(), toFilePath(dataPath()));
}