summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-12-01 15:56:50 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-12-01 15:56:50 +0000
commita5f81e005bfc664a80f99314e62a8620ea152a4d (patch)
treec44c659af1dcf8d57a3a57981328099354771e0e /src
parent6af860412a86dfa9fd1f0ad52f884ecc81daacac (diff)
parent7bd4109cc38ff5c7e736b5c2438dbf0fe8a58b5e (diff)
Merge "Merge branch '5.5' into 5.6" into refs/staging/5.6
Diffstat (limited to 'src')
-rw-r--r--src/webengine/api/qquickwebengineview.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index cef1004cc..5c0e67f70 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -661,6 +661,18 @@ QAccessible::State QQuickWebEngineViewAccessible::state() const
}
#endif // QT_NO_ACCESSIBILITY
+class WebContentsAdapterOwner : public QObject
+{
+public:
+ typedef QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> AdapterPtr;
+ WebContentsAdapterOwner(const AdapterPtr &ptr)
+ : adapter(ptr)
+ {}
+
+private:
+ AdapterPtr adapter;
+};
+
void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContents)
{
if (!webContents) {
@@ -684,6 +696,8 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent
// This throws away the WebContentsAdapter that has been used until now.
// All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter.
+ WebContentsAdapterOwner *adapterOwner = new WebContentsAdapterOwner(adapter);
+ adapterOwner->deleteLater();
adapter = webContents;
adapter->initialize(this);
@@ -867,8 +881,12 @@ void QQuickWebEngineViewPrivate::setProfile(QQuickWebEngineProfile *profile)
if (adapter && adapter->browserContext() != browserContextAdapter()->browserContext()) {
// When the profile changes we need to create a new WebContentAdapter and reload the active URL.
QUrl activeUrl = adapter->activeUrl();
+ QQmlWebChannel *qmlWebChannel = qobject_cast<QQmlWebChannel *>(adapter->webChannel());
adapter = 0;
ensureContentsAdapter();
+ if (qmlWebChannel)
+ adapter->setWebChannel(qmlWebChannel);
+
if (!explicitUrl.isValid() && activeUrl.isValid())
adapter->load(activeUrl);
}