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:
parent
ae8d3d69d6
commit
8f2eb9b43c
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user