summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2019-04-17 12:24:42 +0200
committerMichal Klocek <michal.klocek@qt.io>2019-04-17 11:09:41 +0000
commitc68ba5c0936ba1d1ab00e493c94b540c84255a02 (patch)
treebef3fc9dd37dac2cbdb910cda5490f48290a221e
parent6acd404a409522bca952d48ddb2179ed4f8e6cd5 (diff)
Fix default profile for single-process mode
In single process mode there is only one profile, and this profile is used for browser context. Fix the case where there is no 'default' profile created but only one user profile. In this case make the user profile 'default' so it is deleted in right moment in single process mode. Change-Id: I8ba3c2da2d93d53fa569c7971410a4a74753377e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/web_engine_context.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 7c6b6669d..33cc723f5 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -196,9 +196,9 @@ void WebEngineContext::destroyProfileAdapter()
{
if (content::RenderProcessHost::run_renderer_in_process()) {
Q_ASSERT(m_profileAdapters.count() == 1);
- // this might be default profile
- m_defaultProfileAdapter.release();
- delete m_profileAdapters.first();
+ // this is a default profile
+ m_defaultProfileAdapter.reset();
+ Q_ASSERT(m_profileAdapters.isEmpty());
}
}
@@ -216,9 +216,11 @@ void WebEngineContext::addProfileAdapter(ProfileAdapter *profileAdapter)
}
}
- if (content::RenderProcessHost::run_renderer_in_process() &&
- !m_profileAdapters.isEmpty()) {
- qFatal("Single mode supports only single profile.");
+ if (content::RenderProcessHost::run_renderer_in_process()){
+ if (!m_profileAdapters.isEmpty())
+ qFatal("Single mode supports only single profile.");
+ // there is only one profle therefore make it 'default'
+ m_defaultProfileAdapter.reset(profileAdapter);
}
m_profileAdapters.append(profileAdapter);
}
@@ -307,8 +309,13 @@ WebEngineContext *WebEngineContext::current()
ProfileAdapter *WebEngineContext::createDefaultProfileAdapter()
{
Q_ASSERT(!m_destroyed);
- if (!m_defaultProfileAdapter)
- m_defaultProfileAdapter.reset(new ProfileAdapter(QStringLiteral("Default")));
+ if (!m_defaultProfileAdapter) {
+ ProfileAdapter *profile = new ProfileAdapter(QStringLiteral("Default"));
+ // profile when added to m_profileAdapters might be set default
+ // profile in case of single-process
+ if (!m_defaultProfileAdapter)
+ m_defaultProfileAdapter.reset(profile);
+ }
return m_defaultProfileAdapter.get();
}