diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-12-03 19:36:29 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-12-03 19:36:29 +0100 |
commit | 90d3044e3a6ad58819be6787b5edcbc9daa948dc (patch) | |
tree | 27d54322988fe60a420bbb058608b9b9d637329b /src/webengine/api/qquickwebengineview.cpp | |
parent | 03301c0fbdf034fb987e1c1ed1bec7c206dcd27e (diff) | |
parent | d0ae9b50cc01e4c0f65f17467276d4af40284ae1 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Change-Id: I052fdc4245e25e58457d51f6e49703bc7dd8ff00
Diffstat (limited to 'src/webengine/api/qquickwebengineview.cpp')
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 19ef590b8..9e0da060e 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -669,6 +669,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) { @@ -692,6 +704,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); @@ -875,8 +889,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); } |