Skip to content

Commit 754edb8

Browse files
Michael Bruningjobor
authored andcommitted
Reassociate the web channel when setting a profile.
The WebContentsAdapter gets recreated and the QmlWebChannel needs to be reassociated with the new adapter instance. Change-Id: I88494fd379c429f2ae98df95a22c04c334452088 Task-number: QTBUG-49521 Reviewed-by: Kai Koehne <[email protected]>
1 parent c1ae43b commit 754edb8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/webengine/api/qquickwebengineview.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,12 @@ void QQuickWebEngineViewPrivate::setProfile(QQuickWebEngineProfile *profile)
763763
if (adapter && adapter->browserContext() != browserContextAdapter()->browserContext()) {
764764
// When the profile changes we need to create a new WebContentAdapter and reload the active URL.
765765
QUrl activeUrl = adapter->activeUrl();
766+
QQmlWebChannel *qmlWebChannel = qobject_cast<QQmlWebChannel *>(adapter->webChannel());
766767
adapter = 0;
767768
ensureContentsAdapter();
769+
if (qmlWebChannel)
770+
adapter->setWebChannel(qmlWebChannel);
771+
768772
if (!explicitUrl.isValid() && activeUrl.isValid())
769773
adapter->load(activeUrl);
770774
}

0 commit comments

Comments
 (0)