From 98e90f700a22bf7f139e4993cc96fa91f1183131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 26 Mar 2014 14:10:05 +0100 Subject: 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 Reviewed-by: Sean Harmer --- src/gui/opengl/qopenglvertexarrayobject.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index b1fd4ffdfe..22ca35a8c3 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -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; } -- cgit v1.2.3