From 076440704009ee7566f02fe95a36a16ce4e2fab3 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 23 Mar 2015 11:57:32 +0100 Subject: Avoid crashing in the vao when not supported The stored context pointer has to be reset to null in destroy() even when no VAO was created (vao is null). Otherwise destroying the context that was stored in the VAO will not lead to resetting the stored pointer, and a subsequent destruction of the VAO object will try to dereference it. Task-number: QTBUG-44562 Change-Id: I438bb3954d4bbd8b8d8704f6087479804f0073a7 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Sean Harmer --- src/gui/opengl/qopenglvertexarrayobject.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/gui/opengl/qopenglvertexarrayobject.cpp') diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 6b0f2fede79..2a1b7f4bf4e 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -189,11 +189,16 @@ bool QOpenGLVertexArrayObjectPrivate::create() void QOpenGLVertexArrayObjectPrivate::destroy() { + Q_Q(QOpenGLVertexArrayObject); + + if (context) { + QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); + context = 0; + } + if (!vao) return; - Q_Q(QOpenGLVertexArrayObject); - switch (vaoFuncsType) { #ifndef QT_OPENGL_ES_2 case Core_3_2: @@ -212,10 +217,6 @@ void QOpenGLVertexArrayObjectPrivate::destroy() break; } - Q_ASSERT(context); - QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); - context = 0; - vao = 0; } -- cgit v1.2.3