summaryrefslogtreecommitdiff
path: root/src/webengine/api/qquickwebengineview.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-11-05 14:32:25 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-11-05 14:32:25 +0000
commit09018b99dce7a8ed43b0842055e8775d5021cf04 (patch)
tree8ab6f1b450eb63f981f9275c0f973695d5a3f7b7 /src/webengine/api/qquickwebengineview.cpp
parenta5e14c7abf8fddfbcbc3223e093f8acb50c459d5 (diff)
parent14430b465d39a602d917f2a701218ed56360dc4e (diff)
downloadqtwebengine-09018b99dce7a8ed43b0842055e8775d5021cf04.tar.gz
Merge "Merge branch '5.5' into 5.6" into refs/staging/5.6
Diffstat (limited to 'src/webengine/api/qquickwebengineview.cpp')
-rw-r--r--src/webengine/api/qquickwebengineview.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 52245e147..29f819eb3 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -653,11 +653,25 @@ 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);
+
+ // re-bind the userscrips to the new adapter
+ Q_FOREACH (QQuickWebEngineScript *script, m_userScripts)
+ script->d_func()->bind(browserContextAdapter()->userScriptController(), adapter.data());
+
// Emit signals for values that might be different from the previous WebContentsAdapter.
emit q->titleChanged();
emit q->urlChanged();