summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-08-06 12:55:02 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-08-07 11:20:17 +0000
commitb122e0e32308d95e75aca2fe8f4391180e3c269b (patch)
tree3f3bdc314603ce9ec94ae81754a09abee4f36cdd /src
parent70b7b2bffc09278e1f7210268ffcc871bc6d1c0f (diff)
Guard QGL2PaintEngineEx/QGLPaintDevice against using unset context
QGL2PaintEngineEx::end() calls endPaint() on the device, which may end up calling QGLContext::swapBuffers() on the context, a call which we have documented to require makeCurrent() for any further GL commands: Call this to finish a frame of OpenGL rendering, and make sure to call makeCurrent() again before issuing any further OpenGL commands, for example as part of a new frame. QOpenGLContext also documents that: To be able to support certain platforms, QOpenGLContext requires that you call makeCurrent() again before starting rendering a new frame, after calling swapBuffers(). As a consequence, we need to guard the GL usage in QGLPaintDevice::endPaint(), as well as the GL reset in QGL2PaintEngineEx::end(). Change-Id: Ib66e91cce12fbaea32ed3c30141150fa15907187 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp3
-rw-r--r--src/opengl/qglpaintdevice.cpp1
2 files changed, 2 insertions, 2 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 6365a7421b..cc97bed3f7 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -2099,9 +2099,8 @@ bool QGL2PaintEngineEx::end()
d->device->endPaint();
ctx->d_ptr->active_engine = 0;
-
+ ctx->makeCurrent();
d->resetOpenGLContextActiveEngine();
-
d->resetGLState();
delete d->shaderManager;
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index b29f71ad2e..c5151f66bb 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -126,6 +126,7 @@ void QGLPaintDevice::endPaint()
{
// Make sure the FBO bound at beginPaint is re-bound again here:
QGLContext *ctx = context();
+ ctx->makeCurrent();
ctx->d_func()->refreshCurrentFbo();