summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-06-30 17:41:31 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-07-01 18:31:43 +0000
commit06864c75f4d009bf8fd4e9f88215bb88341ed873 (patch)
treead39aa23e8cc53b3c79a8717ada6aa71371e1a0c /src/webengine
parentea503a2f07f2505d8d91a7d7999a1fb1b1d6b57c (diff)
Switch WebContentsAdapter to using shared pointers
QExplicitSharedDataPointer is meant for value objects, not for shared objects. Instead switch to using QSharedPointer. Change-Id: Ib3791bbcfde627a67508f2819e141d8c538a4a50 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io> Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com>
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebenginenewviewrequest_p.h2
-rw-r--r--src/webengine/api/qquickwebengineview.cpp12
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h4
3 files changed, 9 insertions, 9 deletions
diff --git a/src/webengine/api/qquickwebenginenewviewrequest_p.h b/src/webengine/api/qquickwebenginenewviewrequest_p.h
index b408812ba..c08ef0aba 100644
--- a/src/webengine/api/qquickwebenginenewviewrequest_p.h
+++ b/src/webengine/api/qquickwebenginenewviewrequest_p.h
@@ -72,7 +72,7 @@ private:
QQuickWebEngineNewViewRequest();
QQuickWebEngineView::NewViewDestination m_destination;
bool m_isUserInitiated;
- QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> m_adapter;
+ QSharedPointer<QtWebEngineCore::WebContentsAdapter> m_adapter;
QUrl m_requestedUrl;
friend class QQuickWebEngineView;
friend class QQuickWebEngineViewPrivate;
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index ddca1b670..95aaa39e6 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -527,7 +527,7 @@ void QQuickWebEngineViewPrivate::unhandledKeyEvent(QKeyEvent *event)
q->window()->sendEvent(q->parentItem(), event);
}
-void QQuickWebEngineViewPrivate::adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &)
+void QQuickWebEngineViewPrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &)
{
Q_Q(QQuickWebEngineView);
QQuickWebEngineNewViewRequest request;
@@ -728,7 +728,7 @@ QAccessible::State QQuickWebEngineViewAccessible::state() const
class WebContentsAdapterOwner : public QObject
{
public:
- typedef QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> AdapterPtr;
+ typedef QSharedPointer<QtWebEngineCore::WebContentsAdapter> AdapterPtr;
WebContentsAdapterOwner(const AdapterPtr &ptr)
: adapter(ptr)
{}
@@ -755,9 +755,9 @@ 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);
+ WebContentsAdapterOwner *adapterOwner = new WebContentsAdapterOwner(adapter->sharedFromThis());
adapterOwner->deleteLater();
- adapter = webContents;
+ adapter = webContents->sharedFromThis();
adapter->initialize(this);
// associate the webChannel with the new adapter
@@ -810,7 +810,7 @@ void QQuickWebEngineViewPrivate::ensureContentsAdapter()
{
Q_Q(QQuickWebEngineView);
if (!adapter) {
- adapter = new WebContentsAdapter();
+ adapter = QSharedPointer<WebContentsAdapter>::create();
adapter->initialize(this);
if (m_backgroundColor != Qt::white)
adapter->backgroundColorChanged();
@@ -970,7 +970,7 @@ 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();
- adapter = 0;
+ adapter.reset();
ensureContentsAdapter();
if (!explicitUrl.isValid() && activeUrl.isValid())
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index aab86bc3a..0fd187ab3 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -142,7 +142,7 @@ public:
virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE;
virtual void focusContainer() Q_DECL_OVERRIDE;
virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE;
+ virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE;
virtual bool isBeingAdopted() Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;
virtual void windowCloseRejected() Q_DECL_OVERRIDE;
@@ -190,7 +190,7 @@ public:
static QQuickWebEngineScript *userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx);
static void userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p);
- QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> adapter;
+ QSharedPointer<QtWebEngineCore::WebContentsAdapter> adapter;
QScopedPointer<QQuickWebEngineViewExperimental> e;
QScopedPointer<QQuickWebEngineViewport> v;
QScopedPointer<QQuickWebEngineHistory> m_history;