summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2013-08-08 15:21:51 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-08-12 12:24:24 +0200
commite5531f4cf93cef156deb7d4b290df9620aafb322 (patch)
tree61ab2323bf483feebc9a55ddb07d96b95c91e78e /lib
parent4fdbee3bc4526d4a43b798a095e5168633eb99f5 (diff)
Fix the segfault on exit.
The WebEngineContext member was declared after the WebContentsDelegateQt in WebContentsAdapter. This means that the delegate was destroyed after the context and would cause the crash. Reorder the declaration and move the WebContentsDelegateQt also to the private class to reduce future confusion. Change-Id: I343504d4fd1ede80feb710446368fdf12f360b15 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/web_contents_adapter.cpp23
-rw-r--r--lib/web_contents_adapter.h5
2 files changed, 17 insertions, 11 deletions
diff --git a/lib/web_contents_adapter.cpp b/lib/web_contents_adapter.cpp
index a815628ac..de18e38a0 100644
--- a/lib/web_contents_adapter.cpp
+++ b/lib/web_contents_adapter.cpp
@@ -53,19 +53,25 @@
// Used to maintain a WebEngineContext for as long as we need one
class WebContentsAdapterPrivate {
public:
- WebContentsAdapterPrivate() : engineContext(WebEngineContext::current()) { }
+ WebContentsAdapterPrivate();
scoped_refptr<WebEngineContext> engineContext;
+ QScopedPointer<WebContentsDelegateQt> webContentsDelegate;
};
+WebContentsAdapterPrivate::WebContentsAdapterPrivate()
+ // This has to be the first thing we create, and the last we destroy.
+ : engineContext(WebEngineContext::current())
+{
+}
WebContentsAdapter::WebContentsAdapter(WebContentsAdapterClient *adapterClient)
-// This has to be the first thing we do.
- : d(new WebContentsAdapterPrivate())
+ : d_ptr(new WebContentsAdapterPrivate)
{
+ Q_D(WebContentsAdapter);
content::BrowserContext* browserContext = ContentBrowserClientQt::Get()->browser_context();
- webContentsDelegate.reset(new WebContentsDelegateQt(browserContext, NULL, MSG_ROUTING_NONE, gfx::Size()));
- webContentsDelegate->m_viewClient = adapterClient;
- WebContentsViewQt* contentsView = static_cast<WebContentsViewQt*>(webContentsDelegate->web_contents()->GetView());
+ d->webContentsDelegate.reset(new WebContentsDelegateQt(browserContext, NULL, MSG_ROUTING_NONE, gfx::Size()));
+ d->webContentsDelegate->m_viewClient = adapterClient;
+ WebContentsViewQt* contentsView = static_cast<WebContentsViewQt*>(d->webContentsDelegate->web_contents()->GetView());
contentsView->SetClient(adapterClient);
}
@@ -139,6 +145,7 @@ QString WebContentsAdapter::pageTitle() const
content::WebContents *WebContentsAdapter::webContents() const
{
- Q_ASSERT(webContentsDelegate);
- return webContentsDelegate->web_contents();
+ Q_D(const WebContentsAdapter);
+ Q_ASSERT(d->webContentsDelegate);
+ return d->webContentsDelegate->web_contents();
}
diff --git a/lib/web_contents_adapter.h b/lib/web_contents_adapter.h
index dc65cd0f9..c9d3a67ad 100644
--- a/lib/web_contents_adapter.h
+++ b/lib/web_contents_adapter.h
@@ -51,7 +51,6 @@ namespace content {
class WebContents;
}
class WebContentsAdapterClient;
-class WebContentsDelegateQt;
class WebContentsAdapterPrivate;
class QWEBENGINE_EXPORT WebContentsAdapter {
@@ -72,7 +71,7 @@ public:
private:
inline content::WebContents* webContents() const;
- QScopedPointer<WebContentsDelegateQt> webContentsDelegate;
- QScopedPointer<WebContentsAdapterPrivate> d;
+ Q_DECLARE_PRIVATE(WebContentsAdapter);
+ QScopedPointer<WebContentsAdapterPrivate> d_ptr;
};
#endif // WEB_CONTENTS_ADAPTER_H