QOpenGLWidget: Do not recurse when calling grabFramebuffer() from paintGL()

Task-number: QTBUG-48450
Change-Id: I14b1ff40727f705d8b89371b4d3bb5d6adc139fe
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
This commit is contained in:
Laszlo Agocs 2015-09-28 16:33:29 +02:00
parent e7ab9a1fb9
commit e82e075e51

View File

@ -559,7 +559,8 @@ public:
flushPending(false),
paintDevice(0),
updateBehavior(QOpenGLWidget::NoPartialUpdate),
requestedSamples(0)
requestedSamples(0),
inPaintGL(false)
{
requestedFormat = QSurfaceFormat::defaultFormat();
}
@ -602,6 +603,7 @@ public:
QSurfaceFormat requestedFormat;
QOpenGLWidget::UpdateBehavior updateBehavior;
int requestedSamples;
bool inPaintGL;
};
void QOpenGLWidgetPaintDevicePrivate::beginPaint()
@ -823,7 +825,9 @@ void QOpenGLWidgetPrivate::invokeUserPaint()
QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle();
f->glViewport(0, 0, q->width() * q->devicePixelRatioF(), q->height() * q->devicePixelRatioF());
inPaintGL = true;
q->paintGL();
inPaintGL = false;
flushPending = true;
QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0;
@ -870,7 +874,9 @@ QImage QOpenGLWidgetPrivate::grabFramebuffer()
if (!initialized)
return QImage();
render();
if (!inPaintGL)
render();
resolveSamples();
q->makeCurrent();
QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), false, false);