diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2016-10-27 09:57:54 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2016-11-11 15:34:19 +0000 |
commit | 3654a401f8e046e2fa5a340d0380cc0088a03048 (patch) | |
tree | 1b7f1ffbadd03d78a2b899577c57dd232218e105 | |
parent | e79b40ee8f78a9669ed0b7b6def2a69ef7ab02fa (diff) |
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>
-rw-r--r-- | src/gui/kernel/qopenglcontext_p.h | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopenglframebufferobject.cpp | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 2fe8446c65..736f816bfe 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -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) diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 14581c89f6..be5407ccbd 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -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; + } } /*! |