summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-23 15:14:56 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-14 00:36:29 +0000
commit4560e5f6bccdc0d4ee0104804d36642390ab28d5 (patch)
tree0afd47a677256bd6ded72ce037605cfe22c77361 /src/core
parentb932e1ec5269558728d1f889d96054149e365194 (diff)
Protect against default profile being deleted before its pages
Can really only happen in QML on exit. Task-number: QTBUG-99445 Change-Id: I1a04d57b6c4c40ae264b5519d2e41c57bca79a61 Reviewed-by: Michal Klocek <michal.klocek@qt.io> (cherry picked from commit 45c217646e3742070af15267df8fdb40c2a6c81a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/qwebengineprofile.cpp2
-rw-r--r--src/core/profile_adapter.cpp11
-rw-r--r--src/core/profile_adapter.h1
3 files changed, 11 insertions, 3 deletions
diff --git a/src/core/api/qwebengineprofile.cpp b/src/core/api/qwebengineprofile.cpp
index 5e48f4dd1..85ae00501 100644
--- a/src/core/api/qwebengineprofile.cpp
+++ b/src/core/api/qwebengineprofile.cpp
@@ -183,6 +183,8 @@ QWebEngineProfilePrivate::~QWebEngineProfilePrivate()
if (m_profileAdapter != QtWebEngineCore::ProfileAdapter::defaultProfileAdapter())
delete m_profileAdapter;
+ else if (m_profileAdapter)
+ m_profileAdapter->releaseAllWebContentsAdapterClients();
delete m_settings;
}
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index 6e902ff5a..ccdb2e6c0 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -120,9 +120,8 @@ ProfileAdapter::~ProfileAdapter()
{
m_cancelableTaskTracker->TryCancelAll();
m_profile->NotifyWillBeDestroyed();
- while (!m_webContentsAdapterClients.isEmpty()) {
- m_webContentsAdapterClients.first()->releaseProfile();
- }
+ releaseAllWebContentsAdapterClients();
+
WebEngineContext::current()->removeProfileAdapter(this);
if (m_downloadManagerDelegate) {
m_profile->GetDownloadManager()->Shutdown();
@@ -655,6 +654,12 @@ void ProfileAdapter::removeWebContentsAdapterClient(WebContentsAdapterClient *cl
m_webContentsAdapterClients.removeAll(client);
}
+void ProfileAdapter::releaseAllWebContentsAdapterClients()
+{
+ while (!m_webContentsAdapterClients.isEmpty())
+ m_webContentsAdapterClients.first()->releaseProfile();
+}
+
void ProfileAdapter::resetVisitedLinksManager()
{
m_visitedLinksManager.reset(new VisitedLinksManagerQt(m_profile.data(), persistVisitedLinks()));
diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h
index 373d6e2a9..293ca27ed 100644
--- a/src/core/profile_adapter.h
+++ b/src/core/profile_adapter.h
@@ -137,6 +137,7 @@ public:
void addWebContentsAdapterClient(WebContentsAdapterClient *client);
void removeWebContentsAdapterClient(WebContentsAdapterClient *client);
+ void releaseAllWebContentsAdapterClients();
// KEEP IN SYNC with API or add mapping layer
enum HttpCacheType {