Keep track of destroyed QOpenGLContexts in QOpenGLVertexArrayObject

QOpenGLVertexArrayObject saved the QOpenGLContext it was created in at
the point of QOpenGLVertexArrayObjectPrivate::create(), but didn't set
the saved context back to 0 in QOpenGLVertexArrayObjectPrivate::destroy().

The result was that the zero-pointer checks in the VAO destructor never
hit, and we ended up trying to make a destroyed QOpenGLContext current.

This bug was triggered by the QFontEngine having a limit of 4 concurrent
glyph caches, so when we created the fifth glyph cache we would remove
an earlier one, which destroyed its VOA, that referenced a QOpenGLContext
for a window that had been destroyed already.

We now reset the context back to 0, and disconnect aboutToBeDestroyed()
at the point of QOpenGLVertexArrayObjectPrivate::destroy().

Change-Id: Ib16f3877b310144886cf863b16697c137e7c7941
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
Tor Arne Vestbø 2014-03-26 14:10:05 +01:00 committed by The Qt Project
parent 666c25c089
commit 98e90f700a

View File

@ -149,8 +149,6 @@ bool QOpenGLVertexArrayObjectPrivate::create()
}
Q_Q(QOpenGLVertexArrayObject);
if (context)
QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));
QOpenGLContext *ctx = QOpenGLContext::currentContext();
if (!ctx) {
@ -202,6 +200,8 @@ void QOpenGLVertexArrayObjectPrivate::destroy()
if (!vao)
return;
Q_Q(QOpenGLVertexArrayObject);
switch (vaoFuncsType) {
#ifndef QT_OPENGL_ES_2
case Core_3_2:
@ -220,6 +220,10 @@ void QOpenGLVertexArrayObjectPrivate::destroy()
break;
}
Q_ASSERT(context);
QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));
context = 0;
vao = 0;
}