From 49e660a9e8e47c9cd81bb38f2b74575e7de50aca Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 17 Oct 2019 18:04:51 +0200 Subject: Track request interceptor destroy and update profile io data accordingly On destroy profile level interceptor is cleaned through QPointer in ProfileAdapter but not in ProfileIOData where it is stored as a raw pointer and used by NetworkDelegateQt. Track 'destroyed' signal and clean it from ProfileIOData, which resolves these issues after interceptor is deleted without explicitly being reset in profile: - for deprecated 'setRequestInterceptor': one of possible access violation in NetworkDelegateQt::OnBeforeURLRequest - for setUrlRequestInterceptor: sending URLRequestNotification for every url request after interceptor is deleted Fixes: QTBUG-79156 Change-Id: Ie2dd3f0909bc45748278c5f97c5c2701742591b5 Reviewed-by: Michal Klocek --- src/core/profile_adapter.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index ebb533206..dbe76f0d1 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -179,7 +179,16 @@ void ProfileAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *inte { if (m_requestInterceptor == interceptor) return; + + if (m_requestInterceptor) + disconnect(m_requestInterceptor, &QObject::destroyed, this, nullptr); m_requestInterceptor = interceptor; + if (m_requestInterceptor) + connect(m_requestInterceptor, &QObject::destroyed, this, [this] () { + m_profile->m_profileIOData->updateRequestInterceptor(); + Q_ASSERT(!m_profile->m_profileIOData->requestInterceptor()); + }); + if (m_profile->m_urlRequestContextGetter.get()) m_profile->m_profileIOData->updateRequestInterceptor(); } -- cgit v1.2.3