Prevent stale QOpenGLContext fbo pointer

There is logic for clearing the qgl_curent_fbo pointer
in release(), but it is not always called, causing
the pointer to become stale on QOpenGLFramebufferObject
deletion.

As a last resort, clear the qgl_curent_fbo pointer
on the current context if it’s pointing to the object
that is being deleted.

Change-Id: I36cca511da295412332193524219e32607ef8261
Task-number: QTBUG-56639
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Morten Johan Sørvig 2016-10-27 09:57:54 +02:00
parent ae8d3d69d6
commit 8f2eb9b43c
2 changed files with 7 additions and 1 deletions

View File

@ -258,7 +258,7 @@ public:
static QOpenGLContextPrivate *get(QOpenGLContext *context)
{
return context->d_func();
return context ? context->d_func() : Q_NULLPTR;
}
#if !defined(QT_NO_DEBUG)

View File

@ -949,6 +949,12 @@ QOpenGLFramebufferObject::~QOpenGLFramebufferObject()
d->stencil_buffer_guard->free();
if (d->fbo_guard)
d->fbo_guard->free();
QOpenGLContextPrivate *contextPrv = QOpenGLContextPrivate::get(QOpenGLContext::currentContext());
if (contextPrv && contextPrv->qgl_current_fbo == this) {
contextPrv->qgl_current_fbo_invalid = true;
contextPrv->qgl_current_fbo = Q_NULLPTR;
}
}
/*!