From c33faac32bcf333c990469d455f967599494347a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 18 Sep 2018 13:38:14 +0200 Subject: More fixups for GL_CONTEXT_LOST Fixes the rest of the places we use the pattern of emptying the OpenGL error stack to be able to handle GL_CONTEXT_LOST, and adds a note about it in the documentation. Change-Id: I7eb97dbca45f39295b832d44937023b538b19947 Reviewed-by: David Edmundson Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglbuffer.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/gui/opengl/qopenglbuffer.cpp') diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp index 69c2baa8d97..000494244d9 100644 --- a/src/gui/opengl/qopenglbuffer.cpp +++ b/src/gui/opengl/qopenglbuffer.cpp @@ -43,6 +43,10 @@ #include "qopenglbuffer.h" #include +#ifndef GL_CONTEXT_LOST +#define GL_CONTEXT_LOST 0x0507 +#endif + QT_BEGIN_NAMESPACE /*! @@ -346,7 +350,14 @@ bool QOpenGLBuffer::read(int offset, void *data, int count) Q_D(QOpenGLBuffer); if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers) || !d->guard->id()) return false; - while (d->funcs->glGetError() != GL_NO_ERROR) ; // Clear error state. + + while (true) { // Clear error state. + GLenum error = d->funcs->glGetError(); + if (error == GL_NO_ERROR) + break; + if (error == GL_CONTEXT_LOST) + return false; + }; d->funcs->glGetBufferSubData(d->type, offset, count, data); return d->funcs->glGetError() == GL_NO_ERROR; #else -- cgit v1.2.3