diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-03-10 15:14:43 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-14 21:52:36 +0000 |
commit | 46fefd3d30af65dd3b5f1a7988aa6da61f98e253 (patch) | |
tree | d9e22d568d97a0a6dfe1cd6fb304c9b99b28f6c8 /tests | |
parent | dfe08f92cc85dc2b709cb49b8652989bea354791 (diff) |
Fix losing QOpenGLWidget paints when a child widget is invisible
Change-Id: I136b486d30e31acadd6b1b837dc7e834ee3e23fb
Fixes: QTBUG-101620
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
(cherry picked from commit 1ea73bc29b7542141bfcfa138cc194404c283bd5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index 3d7bb36f24..12ea9e6eef 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -66,6 +66,7 @@ private slots: void stackWidgetOpaqueChildIsVisible(); void offscreen(); void offscreenThenOnscreen(); + void paintWhileHidden(); #ifdef QT_BUILD_INTERNAL void staticTextDanglingPointer(); @@ -694,6 +695,30 @@ void tst_QOpenGLWidget::offscreenThenOnscreen() QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255)); } +void tst_QOpenGLWidget::paintWhileHidden() +{ + QScopedPointer<QWidget> tlw(new QWidget); + tlw->resize(640, 480); + + ClearWidget *w = new ClearWidget(0, 640, 480); + w->setParent(tlw.data()); + w->setClearColor(0, 0, 1); + + tlw->show(); + QVERIFY(QTest::qWaitForWindowExposed(tlw.data())); + + // QTBUG-101620: Now make visible=false and call update and see if we get to + // paintEvent/paintGL eventually, to ensure the updating of the texture is + // not optimized permanently away even though there is no composition + // on-screen at the point when update() is called. + + w->setVisible(false); + w->m_paintCalled = 0; + w->update(); + w->setVisible(true); + QTRY_VERIFY(w->m_paintCalled > 0); +} + class StaticTextPainterWidget : public QOpenGLWidget { public: |