From 50a1cd3aac4a6e04cb4931f20996c353318fed03 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Thu, 14 Apr 2016 17:49:11 +0200 Subject: 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 --- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp') 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 window(qobject_cast(component.create())); + QVERIFY(!window.isNull()); + window->setTitle(QTest::currentTestFunction()); + window->show(); + QTest::qWaitForWindowExposed(window.data()); + QPointer winVisible; + QTRY_VERIFY(winVisible = window->property("winVisible").value()); + QPointer winVisibility; + QTRY_VERIFY(winVisibility = window->property("winVisibility").value()); + QTest::qWaitForWindowExposed(winVisible); + QTest::qWaitForWindowExposed(winVisibility); + + QVERIFY(winVisible->isVisible()); + QCOMPARE(winVisibility->visibility(), QWindow::Windowed); +} + // QTBUG-32004 void tst_qquickwindow::qobjectEventFilter_touch() { -- cgit v1.2.3