Skip to content

Commit b27161b

Browse files
Tofeecarewolf
authored andcommitted
adoptWebContents: re-associate webchannel with new adapter
Task-number: QTBUG-48984 Change-Id: Ief41fe9619f4300d7a0c25a57f09f5eefe3fca3d Reviewed-by: Allan Sandfeld Jensen <[email protected]>
1 parent 09a341f commit b27161b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/webengine/api/qquickwebengineview.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,21 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent
558558
}
559559

560560
Q_Q(QQuickWebEngineView);
561+
562+
// memorize what webChannel we had for the previous adapter
563+
QQmlWebChannel *qmlWebChannel = NULL;
564+
if (adapter)
565+
qmlWebChannel = qobject_cast<QQmlWebChannel *>(adapter->webChannel());
566+
561567
// This throws away the WebContentsAdapter that has been used until now.
562568
// All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter.
563569
adapter = webContents;
564570
adapter->initialize(this);
565571

572+
// associate the webChannel with the new adapter
573+
if (qmlWebChannel)
574+
adapter->setWebChannel(qmlWebChannel);
575+
566576
// Emit signals for values that might be different from the previous WebContentsAdapter.
567577
emit q->titleChanged();
568578
emit q->urlChanged();

0 commit comments

Comments
 (0)