summaryrefslogtreecommitdiffstats
path: root/src/webengine/api/qquickwebengineview.cpp
diff options
context:
space:
mode:
authorChristophe Chapuis <chris.chapuis@gmail.com>2015-10-28 18:45:57 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-28 17:59:48 +0000
commitb27161b6057295e43d5a45646a8cf22d4aefa18e (patch)
tree09abbd0f46d6df5827d58ad6c9364a035813a5c8 /src/webengine/api/qquickwebengineview.cpp
parent09a341f4a62a0fe244dc188a75d77d0067ad1fe7 (diff)
adoptWebContents: re-associate webchannel with new adapter
Task-number: QTBUG-48984 Change-Id: Ief41fe9619f4300d7a0c25a57f09f5eefe3fca3d Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/webengine/api/qquickwebengineview.cpp')
-rw-r--r--src/webengine/api/qquickwebengineview.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 6c3452a6a..129cfd2de 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -558,11 +558,21 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent
}
Q_Q(QQuickWebEngineView);
+
+ // memorize what webChannel we had for the previous adapter
+ QQmlWebChannel *qmlWebChannel = NULL;
+ if (adapter)
+ qmlWebChannel = qobject_cast<QQmlWebChannel *>(adapter->webChannel());
+
// This throws away the WebContentsAdapter that has been used until now.
// All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter.
adapter = webContents;
adapter->initialize(this);
+ // associate the webChannel with the new adapter
+ if (qmlWebChannel)
+ adapter->setWebChannel(qmlWebChannel);
+
// Emit signals for values that might be different from the previous WebContentsAdapter.
emit q->titleChanged();
emit q->urlChanged();