diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 7eb2a350d35..dcdbaedc202 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -320,7 +320,7 @@ void QCocoaWindow::setVisible(bool visible) return; // We'll get another setVisible call after create is done } - if (visible == !m_view.hidden) { + if (visible == !m_view.hidden && (!isContentView() || visible == m_view.window.visible)) { qCDebug(lcQpaWindow) << "No change in visible status. Ignoring."; return; } diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index fa7ab96efe6..5fa84b31eed 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -94,6 +94,7 @@ private slots: void enterLeaveOnWindowShowHide_data(); void enterLeaveOnWindowShowHide(); #endif + void windowExposedAfterReparent(); private: QPoint m_availableTopLeft; @@ -3003,6 +3004,25 @@ void tst_QWindow::enterLeaveOnWindowShowHide() } #endif +void tst_QWindow::windowExposedAfterReparent() +{ + QWindow parent; + QWindow child(&parent); + child.show(); + parent.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&parent)); + QVERIFY(QTest::qWaitForWindowExposed(&child)); + + child.setParent(nullptr); + QCoreApplication::processEvents(); + QVERIFY(QTest::qWaitForWindowExposed(&child)); + + child.setParent(&parent); + QCoreApplication::processEvents(); + QVERIFY(QTest::qWaitForWindowExposed(&child)); +} + #include QTEST_MAIN(tst_QWindow)