From 3ce5128d8062b7eca4925454610bd1df9db9d77a Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 5 Jan 2021 13:22:44 +0100 Subject: 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. Pick-to: 6.0 5.15 Fixes: QTBUG-89812 Change-Id: I3c4560f8f069d86645a6314bf7ad1b4ee8e2c716 Reviewed-by: Andy Nichols --- src/openglwidgets/qopenglwidget.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/openglwidgets/qopenglwidget.cpp b/src/openglwidgets/qopenglwidget.cpp index 8dbb9180f4..a596416471 100644 --- a/src/openglwidgets/qopenglwidget.cpp +++ b/src/openglwidgets/qopenglwidget.cpp @@ -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: -- cgit v1.2.3