summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2016-10-27 09:57:54 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2016-11-08 12:30:24 +0000
commit8f2eb9b43c23b03918c50fa721a47f3ab99e4ec6 (patch)
tree936a4628f8ec52253a9fd568c923e360b27972fc /src
parentae8d3d69d68e7f3da1b0f524e12496387aff26ec (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: I36cca511da295412332193524219e32607ef8261 Task-number: QTBUG-56639 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qopenglcontext_p.h2
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index 7c8c698a7d..113b789512 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -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)
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index b1b580f85b..b5fa6b9785 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -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;
+ }
}
/*!