summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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()));
}