diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-11-27 10:51:10 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-11-27 10:51:26 +0100 |
commit | 7bd4109cc38ff5c7e736b5c2438dbf0fe8a58b5e (patch) | |
tree | 4ff0dacd507985d930071599287bc104db539867 /src/webengine | |
parent | e68d1ad06599eae1b0785263f3a0863701e6f1bc (diff) | |
parent | 754edb8dadb9b3086f67eadabdde9659dfcb7caf (diff) |
Merge branch '5.5' into 5.6
Change-Id: Ie1f05c97650ecb86a6fe2d69ad037790c315a83b
Diffstat (limited to 'src/webengine')
-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 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); } |