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>
This commit is contained in:
Tor Arne Vestbø 2018-08-06 12:55:02 +02:00
parent 70b7b2bffc
commit b122e0e323
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -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();