summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSérgio Martins <sergio.martins@kdab.com>2017-06-13 12:09:59 +0100
committerSérgio Martins <sergio.martins@kdab.com>2017-07-02 09:31:01 +0000
commitfd897629bf698c9efb4628188db79f2937ef3d89 (patch)
tree6a02b46f7c25d18aa8b1a82d01b579a85a91564c /tests
parent628f3becf929efa284628884716bc2ea772c4cc6 (diff)
Fix moving a hidden QOpenGLWidget to another window
A visibile QOpenGLWidget receives a QEvent::WindowChangeInternal which triggers a QOpenGLWidget::reset(). A hidden QOpenGLWidget never received this event so it was never reset, resulting in a black rendering. Includes unit-test that fails without this patch. Change-Id: I9d2c57d66fa629f631a9829a5ebf4de09998ad75 Task-Id: QTBUG-60896 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
index f51c566f20..2a05900adc 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
+++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
@@ -55,6 +55,7 @@ private slots:
void painter();
void reparentToAlreadyCreated();
void reparentToNotYetCreated();
+ void reparentHidden();
void asViewport();
void requestUpdate();
void fboRedirect();
@@ -279,6 +280,36 @@ void tst_QOpenGLWidget::reparentToNotYetCreated()
QVERIFY(image.pixel(20, 10) == qRgb(0, 0, 255));
}
+void tst_QOpenGLWidget::reparentHidden()
+{
+ // Tests QTBUG-60896
+ QWidget topLevel1;
+
+ QWidget *container = new QWidget(&topLevel1);
+ PainterWidget *glw = new PainterWidget(container);
+ topLevel1.resize(640, 480);
+ glw->resize(320, 200);
+ topLevel1.show();
+
+ glw->hide(); // Explicitly hidden
+
+ QTest::qWaitForWindowExposed(&topLevel1);
+
+ QWidget topLevel2;
+ topLevel2.resize(640, 480);
+ topLevel2.show();
+ QTest::qWaitForWindowExposed(&topLevel2);
+
+ QOpenGLContext *originalContext = glw->context();
+ QVERIFY(originalContext);
+
+ container->setParent(&topLevel2);
+ glw->show(); // Should get a new context now
+
+ QOpenGLContext *newContext = glw->context();
+ QVERIFY(originalContext != newContext);
+}
+
class CountingGraphicsView : public QGraphicsView
{
public: