aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2016-04-14 17:49:11 +0200
committerRobert Griebl <robert.griebl@pelagicore.com>2016-04-18 19:26:25 +0000
commit50a1cd3aac4a6e04cb4931f20996c353318fed03 (patch)
tree648b704a8a5a4c6092ee868e06f2b9c9b5acfa85 /tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
parent6753b1c84219d1e615bda8515332b187f21ca094 (diff)
Fix changing QML Window visibility in Component.onCompleted
Creating a transient QML Window with visible set to false and then trying to show() it in Component.onCompleted led to a race condition where the window would be shown for a brief moment and then hidden again to enforce the delayed initialization of the visible property. Fixed by tracking the value of the visible property regardless of the 'completed' state. The same problem was fixed for the visibility property. Task-number: QTBUG-52573 Change-Id: I2a2ed7f359b951cb9189a7a6628d1d0cc1445d73 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp')
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index ff8c80e3ae..526f61ceb5 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -346,6 +346,7 @@ private slots:
void crashWhenHoverItemDeleted();
void unloadSubWindow();
+ void changeVisibilityInCompleted();
void qobjectEventFilter_touch();
void qobjectEventFilter_key();
@@ -1847,6 +1848,28 @@ void tst_qquickwindow::unloadSubWindow()
QTRY_VERIFY(transient.isNull() || !transient->isVisible());
}
+// QTBUG-52573
+void tst_qquickwindow::changeVisibilityInCompleted()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("changeVisibilityInCompleted.qml"));
+ QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create()));
+ QVERIFY(!window.isNull());
+ window->setTitle(QTest::currentTestFunction());
+ window->show();
+ QTest::qWaitForWindowExposed(window.data());
+ QPointer<QQuickWindow> winVisible;
+ QTRY_VERIFY(winVisible = window->property("winVisible").value<QQuickWindow*>());
+ QPointer<QQuickWindow> winVisibility;
+ QTRY_VERIFY(winVisibility = window->property("winVisibility").value<QQuickWindow*>());
+ QTest::qWaitForWindowExposed(winVisible);
+ QTest::qWaitForWindowExposed(winVisibility);
+
+ QVERIFY(winVisible->isVisible());
+ QCOMPARE(winVisibility->visibility(), QWindow::Windowed);
+}
+
// QTBUG-32004
void tst_qquickwindow::qobjectEventFilter_touch()
{