From 7f6497e623fd66e0dc1ecab89ef16533154a6472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 15 Nov 2018 22:26:55 +0100 Subject: Ensure QOpenGLWidget FBO is always initialized QOpenGLWidget uses an FBO internally, that is glCleared whenever recreated. But for the clear to be visible across shared contexts we must also issue a glFlush. QOpenGLWidget defers this flush until the compositing step, in QOpenGLWidgetPrivate::beginCompose(), based on a flushPending variable. This variable is set either after invoking the user's paintGL() function, or when opening a QPainter on the QOpenGLWidget, via QOpenGLWidgetPaintDevice::ensureActiveTarget(). Unfortunately, if QOpenGLWidget::paintEvent() is overridden or intercepted (meaning we will not end up calling paintGL()), but the overridden paint event does not open a QPainter, we end up never setting flushPending to true, and end up composing an uninitialized FBO. This can lead to rendering issues, or even kernel panics with some unfortunate GL drivers. The fix is to ensure the glClear is always flushed before composing, by forcing a pending flush whenever the FBO is recreated. Fixes: QTBUG-70921 Change-Id: I72b596c09dcf54bd0f37668062daaad2d6f7f4bd Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qopenglwidget.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index c96b6812c4..53dc88bd2c 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -756,6 +756,7 @@ void QOpenGLWidgetPrivate::recreateFbo() fbo->bind(); context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + flushPending = true; // Make sure the FBO is initialized before use paintDevice->setSize(deviceSize); paintDevice->setDevicePixelRatio(q->devicePixelRatioF()); -- cgit v1.2.3