summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohan Chuzeville <ychuzevi@cisco.com>2015-04-13 11:24:33 +0200
committerYohan Chuzeville <ychuzevi@cisco.com>2015-04-13 10:05:35 +0000
commit738ad7e37c66f2afdbc7a77aff3ab7fa510361a2 (patch)
treebf9900f7ab5637692582696670ae0c6e8a6efc9c
parentb653da9a88901fbc44114cac9232a6a332d2d0a7 (diff)
Fix crash when exiting browser with WebGL or accelerated canvas.
Issue is that the TextureMapperGL creates a GraphicsContext3D using the current OpenGL context. This is done by storing a reference on QOpenGLContext::currentContext() inside GraphicsContext3DPrivate::GraphicsContext3DPrivate(). When exiting the browser, Qt releases QOpenGLContext before the release of the GraphicsContext3D in webkit which leads to a crash when destoying GraphicsContext3DPrivate. Task-number: QTBUG-45481 Change-Id: I2b9d7b1a96fbbe8517ea323d45ef3922ada208a3 Reviewed-by: Julien Brianceau <jbriance@cisco.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index 155678d94..dffcfc637 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -111,6 +111,18 @@ public:
GraphicsSurface::Flags m_surfaceFlags;
RefPtr<GraphicsSurface> m_graphicsSurface;
#endif
+
+ // Register as a child of a Qt context to make the necessary when it may be destroyed before the GraphicsContext3D instance
+ class QtContextWatcher : public QObject
+ {
+ public:
+ QtContextWatcher(QObject* ctx, GraphicsContext3DPrivate* watcher): QObject(ctx), m_watcher(watcher) { }
+ ~QtContextWatcher() { m_watcher->m_platformContext = 0; m_watcher->m_platformContextWatcher = 0; }
+
+ private:
+ GraphicsContext3DPrivate* m_watcher;
+ };
+ QtContextWatcher* m_platformContextWatcher;
};
bool GraphicsContext3DPrivate::isOpenGLES() const
@@ -149,11 +161,16 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H
, m_surface(0)
, m_platformContext(0)
, m_surfaceOwner(0)
+ , m_platformContextWatcher(0)
{
if (renderStyle == GraphicsContext3D::RenderToCurrentGLContext) {
m_platformContext = QOpenGLContext::currentContext();
if (m_platformContext)
m_surface = m_platformContext->surface();
+
+ // Watcher needed to invalidate the GL context if destroyed before this instance
+ m_platformContextWatcher = new QtContextWatcher(m_platformContext, this);
+
initializeOpenGLFunctions();
return;
}
@@ -260,6 +277,9 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
#endif
delete m_surfaceOwner;
m_surfaceOwner = 0;
+
+ delete m_platformContextWatcher;
+ m_platformContextWatcher = 0;
}
#if USE(ACCELERATED_COMPOSITING)