From 06864c75f4d009bf8fd4e9f88215bb88341ed873 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 30 Jun 2016 17:41:31 +0200 Subject: Switch WebContentsAdapter to using shared pointers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QExplicitSharedDataPointer is meant for value objects, not for shared objects. Instead switch to using QSharedPointer. Change-Id: Ib3791bbcfde627a67508f2819e141d8c538a4a50 Reviewed-by: Michael BrĂ¼ning Reviewed-by: Michal Klocek --- src/webenginewidgets/api/qwebenginepage.cpp | 12 ++++++------ src/webenginewidgets/api/qwebenginepage_p.h | 4 ++-- src/webenginewidgets/api/qwebenginescriptcollection.cpp | 12 ++++++------ src/webenginewidgets/api/qwebenginescriptcollection_p.h | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/webenginewidgets/api') diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index b35bb54ec..9685d19f1 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -120,13 +120,13 @@ QWebEnginePage::WebAction editorActionForKeyEvent(QKeyEvent* event) } QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) - : adapter(new WebContentsAdapter) + : adapter(QSharedPointer::create()) , history(new QWebEngineHistory(new QWebEngineHistoryPrivate(this))) , profile(_profile ? _profile : QWebEngineProfile::defaultProfile()) , settings(new QWebEngineSettings(profile->settings())) , view(0) , isLoading(false) - , scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userScriptController(), adapter.data())) + , scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userScriptController(), adapter)) , m_isBeingAdopted(false) , m_backgroundColor(Qt::white) , fullscreenMode(false) @@ -266,7 +266,7 @@ void QWebEnginePagePrivate::unhandledKeyEvent(QKeyEvent *event) QGuiApplication::sendEvent(view->parentWidget(), event); } -void QWebEnginePagePrivate::adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry) +void QWebEnginePagePrivate::adoptNewWindow(QSharedPointer newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry) { Q_Q(QWebEnginePage); Q_UNUSED(userGesture); @@ -451,13 +451,13 @@ void QWebEnginePagePrivate::_q_webActionTriggered(bool checked) void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input) { - QExplicitlySharedDataPointer newWebContents = WebContentsAdapter::createFromSerializedNavigationHistory(input, this); + QSharedPointer newWebContents = WebContentsAdapter::createFromSerializedNavigationHistory(input, this); if (newWebContents) { - adapter = newWebContents.data(); + adapter = std::move(newWebContents); adapter->initialize(this); if (webChannel) adapter->setWebChannel(webChannel); - scriptCollection.d->rebindToContents(adapter.data()); + scriptCollection.d->rebindToContents(adapter); } } diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index d0023d7bb..41ba84dd0 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -95,7 +95,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 &initialGeometry) Q_DECL_OVERRIDE; + virtual void adoptNewWindow(QSharedPointer newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry) Q_DECL_OVERRIDE; virtual bool isBeingAdopted() Q_DECL_OVERRIDE; virtual void close() Q_DECL_OVERRIDE; virtual void windowCloseRejected() Q_DECL_OVERRIDE; @@ -143,7 +143,7 @@ public: void setFullScreenMode(bool); - QExplicitlySharedDataPointer adapter; + QSharedPointer adapter; QWebEngineHistory *history; QWebEngineProfile *profile; QWebEngineSettings *settings; diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp index 8d581b60a..1ba16db9d 100644 --- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp +++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp @@ -164,7 +164,7 @@ QList QWebEngineScriptCollection::toList() const } -QWebEngineScriptCollectionPrivate::QWebEngineScriptCollectionPrivate(QtWebEngineCore::UserScriptControllerHost *controller, QtWebEngineCore::WebContentsAdapter *webContents) +QWebEngineScriptCollectionPrivate::QWebEngineScriptCollectionPrivate(QtWebEngineCore::UserScriptControllerHost *controller, QSharedPointer webContents) : m_scriptController(controller) , m_contents(webContents) { @@ -221,14 +221,14 @@ void QWebEngineScriptCollectionPrivate::reserve(int capacity) m_scriptController->reserve(m_contents.data(), capacity); } -void QWebEngineScriptCollectionPrivate::rebindToContents(QtWebEngineCore::WebContentsAdapter *page) +void QWebEngineScriptCollectionPrivate::rebindToContents(QSharedPointer contents) { Q_ASSERT(m_contents); - Q_ASSERT(page); - Q_ASSERT(m_contents != page); + Q_ASSERT(contents); + Q_ASSERT(m_contents != contents); Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents.data())) { - m_scriptController->addUserScript(script, page); + m_scriptController->addUserScript(script, contents.data()); } - m_contents = page; + m_contents = contents; } diff --git a/src/webenginewidgets/api/qwebenginescriptcollection_p.h b/src/webenginewidgets/api/qwebenginescriptcollection_p.h index 931f6c0e8..911764868 100644 --- a/src/webenginewidgets/api/qwebenginescriptcollection_p.h +++ b/src/webenginewidgets/api/qwebenginescriptcollection_p.h @@ -53,8 +53,8 @@ #include "qwebenginescript.h" #include "web_contents_adapter.h" -#include #include +#include namespace QtWebEngineCore { class UserScriptControllerHost; @@ -63,14 +63,14 @@ class UserScriptControllerHost; QT_BEGIN_NAMESPACE class QWebEngineScriptCollectionPrivate { public: - QWebEngineScriptCollectionPrivate(QtWebEngineCore::UserScriptControllerHost *, QtWebEngineCore::WebContentsAdapter * = 0); + QWebEngineScriptCollectionPrivate(QtWebEngineCore::UserScriptControllerHost *, QSharedPointer = QSharedPointer()); int count() const; bool contains(const QWebEngineScript &) const; QList toList(const QString &scriptName = QString()) const; QWebEngineScript find(const QString & name) const; - void rebindToContents(QtWebEngineCore::WebContentsAdapter *contents); + void rebindToContents(QSharedPointer contents); void insert(const QWebEngineScript &); bool remove(const QWebEngineScript &); @@ -79,7 +79,7 @@ public: private: QtWebEngineCore::UserScriptControllerHost *m_scriptController; - QExplicitlySharedDataPointer m_contents; + QSharedPointer m_contents; }; QT_END_NAMESPACE -- cgit v1.2.3