Fix missing repaints with QOpenGLWidget in a QDockWidget

When AA_ShareOpenGLContexts is not set, docking or undocking
will lead to changing the associated top-level window. This
leads to changing the OpenGL context, and tearing down and
then recreating all OpenGL resources (assuming a well written
application). The problem is, there are no paint events after
the Show, meaning the user code's paintGL is often not invoked,
which leads to showing an empty QOpenGLWidget until something
else triggers a paint event. To remedy this, send a paint event
upon Show, which should be harmless enough, while fixing the
case of docking/undocking.

Fixes: QTBUG-89812
Change-Id: I3c4560f8f069d86645a6314bf7ad1b4ee8e2c716
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 3ce5128d8062b7eca4925454610bd1df9db9d77a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Laszlo Agocs 2021-01-05 13:22:44 +01:00 committed by Qt Cherry-pick Bot
parent 254aa011b1
commit 340f777e01

View File

@ -1381,8 +1381,13 @@ bool QOpenGLWidget::event(QEvent *e)
}
if (!d->initialized && !size().isEmpty() && window()->windowHandle()) {
d->initialize();
if (d->initialized)
if (d->initialized) {
d->recreateFbo();
// QTBUG-89812: generate a paint event, like resize would do,
// otherwise a QOpenGLWidget in a QDockWidget may not show the
// content upon (un)docking.
d->sendPaintEvent(QRect(QPoint(0, 0), size()));
}
}
break;
case QEvent::ScreenChangeInternal: