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 <giuseppe.dangelo@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
Laszlo Agocs 2015-03-23 11:57:32 +01:00
parent dc62f15d79
commit 0764407040

View File

@ -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;
}