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: I0a91d686cec5fcbe4c1520a9ba96cea833bb2249
Task-number: QTBUG-56639
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
bb10
Morten Johan Sørvig 2016-10-27 09:57:54 +02:00 committed by Jani Heikkinen
parent e79b40ee8f
commit 3654a401f8
2 changed files with 7 additions and 1 deletions

View File

@ -264,7 +264,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

@ -955,6 +955,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;
}
}
/*!