From b122e0e32308d95e75aca2fe8f4391180e3c269b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 6 Aug 2018 12:55:02 +0200 Subject: Guard QGL2PaintEngineEx/QGLPaintDevice against using unset context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tor Arne Vestbø --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 3 +-- src/opengl/qglpaintdevice.cpp | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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(); -- cgit v1.2.3