Commit b3d286ab authored by Jocelyn Turcotte's avatar Jocelyn Turcotte
Browse files

Ref-count WebContentsAdapter.


This is needed to handle createWindow where a WebContentsAdapter will
be created to wrap the new WebContents and will passed up through the
API. If the application doesn't handle the callback, this will allow
managing the lifetime of the WebContents more easily.

Change-Id: I40ae1973a9bdf8c3d75f9ff137228d48ed92cfb2
Reviewed-by: default avatarAndras Becsi <andras.becsi@digia.com>
Showing with 7 additions and 5 deletions
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include "web_contents_adapter_client.h" #include "web_contents_adapter_client.h"
#include <QScopedPointer> #include <QSharedData>
#include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquickitem_p.h>
class QQuickWebEngineView; class QQuickWebEngineView;
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
virtual void loadFinished(bool success) Q_DECL_OVERRIDE; virtual void loadFinished(bool success) Q_DECL_OVERRIDE;
virtual void focusContainer() Q_DECL_OVERRIDE; virtual void focusContainer() Q_DECL_OVERRIDE;
QScopedPointer<WebContentsAdapter> adapter; QExplicitlySharedDataPointer<WebContentsAdapter> adapter;
friend class RenderWidgetHostViewQtDelegateQuick; friend class RenderWidgetHostViewQtDelegateQuick;
}; };
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "qtwebengineglobal.h" #include "qtwebengineglobal.h"
#include <QScopedPointer> #include <QScopedPointer>
#include <QSharedData>
#include <QString> #include <QString>
#include <QUrl> #include <QUrl>
...@@ -53,7 +54,7 @@ class WebContents; ...@@ -53,7 +54,7 @@ class WebContents;
class WebContentsAdapterClient; class WebContentsAdapterClient;
class WebContentsAdapterPrivate; class WebContentsAdapterPrivate;
class QWEBENGINE_EXPORT WebContentsAdapter { class QWEBENGINE_EXPORT WebContentsAdapter : public QSharedData {
public: public:
WebContentsAdapter(WebContentsAdapterClient* adapterClient); WebContentsAdapter(WebContentsAdapterClient* adapterClient);
...@@ -78,6 +79,7 @@ public: ...@@ -78,6 +79,7 @@ public:
void clearNavigationHistory(); void clearNavigationHistory();
private: private:
Q_DISABLE_COPY(WebContentsAdapter);
Q_DECLARE_PRIVATE(WebContentsAdapter); Q_DECLARE_PRIVATE(WebContentsAdapter);
QScopedPointer<WebContentsAdapterPrivate> d_ptr; QScopedPointer<WebContentsAdapterPrivate> d_ptr;
}; };
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#include "web_contents_adapter_client.h" #include "web_contents_adapter_client.h"
#include <QtCore/private/qobject_p.h> #include <QtCore/private/qobject_p.h>
#include <QScopedPointer> #include <QSharedData>
class QWebEngineHistory; class QWebEngineHistory;
class QWebEnginePage; class QWebEnginePage;
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
void updateNavigationActions(); void updateNavigationActions();
void _q_webActionTriggered(bool checked); void _q_webActionTriggered(bool checked);
QScopedPointer<WebContentsAdapter> adapter; QExplicitlySharedDataPointer<WebContentsAdapter> adapter;
QWebEngineHistory *history; QWebEngineHistory *history;
QWebEngineView *view; QWebEngineView *view;
mutable QAction *actions[QWebEnginePage::WebActionCount]; mutable QAction *actions[QWebEnginePage::WebActionCount];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment