summaryrefslogtreecommitdiffstats
path: root/src/core/web_engine_context.cpp
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2018-01-12 13:44:07 +0100
committerMichal Klocek <michal.klocek@qt.io>2018-05-23 09:42:34 +0000
commitf012238341216c2355dc724ea8e7de74fa764cc0 (patch)
tree1aef35f411c4e1e788e191ad5809771572bc0841 /src/core/web_engine_context.cpp
parent45ec7b64755546438943caf68629dc84e0068d36 (diff)
Track BrowserContextAdapter in WebEngineContext
Instead of keeping BrowserContextAdapter as a child of global object add them to the list kept by WebEngineContext. Change-Id: I626ca6ff6dec3eb76530e3cfb6d589cb961a5795 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/web_engine_context.cpp')
-rw-r--r--src/core/web_engine_context.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index af22c5e7f..3e3a99f7a 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -186,7 +186,28 @@ bool WebEngineContext::m_destroyed = false;
void WebEngineContext::destroyBrowserContext()
{
if (m_defaultBrowserContext)
- qWarning() << "PostMainMessageLoopRun is done, but global profile still exists !";
+ qWarning("PostMainMessageLoopRun is done, but global profile still exists !");
+}
+
+void WebEngineContext::addBrowserContext(BrowserContextAdapter *contextAdapter)
+{
+ Q_ASSERT(!m_browserContextAdapters.contains(contextAdapter));
+ const QString path = contextAdapter->dataPath();
+ if (!path.isEmpty()) {
+ for (auto browserContextAdapter : m_browserContextAdapters) {
+ if (browserContextAdapter->dataPath() == path) {
+ // QTBUG-66068
+ qWarning("Using the same data path for profile, may corrupt the data.");
+ break;
+ }
+ }
+ }
+ m_browserContextAdapters.append(contextAdapter);
+}
+
+void WebEngineContext::removeBrowserContext(BrowserContextAdapter *contextAdapter)
+{
+ m_browserContextAdapters.removeAll(contextAdapter);
}
void WebEngineContext::destroy()
@@ -201,6 +222,8 @@ void WebEngineContext::destroy()
// Delete the global object and thus custom profiles
m_defaultBrowserContext.reset();
m_globalQObject.reset();
+ while (m_browserContextAdapters.count())
+ delete m_browserContextAdapters.first();
// Handle any events posted by browser-context shutdown.
while (delegate->DoWork()) { }
@@ -224,6 +247,7 @@ WebEngineContext::~WebEngineContext()
Q_ASSERT(!m_globalQObject);
Q_ASSERT(!m_devtoolsServer);
Q_ASSERT(!m_browserRunner);
+ Q_ASSERT(m_browserContextAdapters.isEmpty());
}
WebEngineContext *WebEngineContext::current()