diff options
author | Vladimir Belyavsky <belyavskyv@gmail.com> | 2024-03-01 15:36:14 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-03-04 23:39:45 +0000 |
commit | 92446b9de8f66d5f730cdab1ec8907bda30b2c65 (patch) | |
tree | f5e06b5d4bf43388ace54f5fa83ef9bcb9b033a4 | |
parent | 485388263f55ac7c40c53fa3b0d4bfaa275e55f1 (diff) |
QQuickPopup: always run exit transition on hiding a popup
Amends c16dc16cafa78ea2a3d1ef6e374f46d6632da779. Do actually what
the comment said "Do not start EnterTransition for a popup in
QQuickPopup::setVisible() when the popup is not yet associated with
any window" but do _not_ touch original ExitTransition logic.
Fixes: QTBUG-122915
Pick-to: 6.6
Change-Id: I77db41254d1c1966f4b3b5285e26efd0487da51b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
(cherry picked from commit 30ae9e99e275d9c2288a14120b36f763a9d88c78)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/quicktemplates/qquickpopup.cpp | 13 | ||||
-rw-r--r-- | tests/auto/quickcontrols/controls/data/tst_popup.qml | 31 |
2 files changed, 38 insertions, 6 deletions
diff --git a/src/quicktemplates/qquickpopup.cpp b/src/quicktemplates/qquickpopup.cpp index 3434bdace2..43bf1f447a 100644 --- a/src/quicktemplates/qquickpopup.cpp +++ b/src/quicktemplates/qquickpopup.cpp @@ -2149,14 +2149,15 @@ void QQuickPopup::setVisible(bool visible) if (d->visible == visible && d->transitionState != QQuickPopupPrivate::ExitTransition) return; - if (d->complete && d->window) { - if (visible) - d->transitionManager.transitionEnter(); - else - d->transitionManager.transitionExit(); - } else { + if (!d->complete || (visible && !d->window)) { d->visible = visible; + return; } + + if (visible) + d->transitionManager.transitionEnter(); + else + d->transitionManager.transitionExit(); } /*! diff --git a/tests/auto/quickcontrols/controls/data/tst_popup.qml b/tests/auto/quickcontrols/controls/data/tst_popup.qml index ca8790e09e..1257148761 100644 --- a/tests/auto/quickcontrols/controls/data/tst_popup.qml +++ b/tests/auto/quickcontrols/controls/data/tst_popup.qml @@ -1525,4 +1525,35 @@ TestCase { compare(control.y, control.parent.height / 2 - control.height / 2) control.close() } + + Component { + id: popupWithOverlayInLoader + + Loader { + id: loader + active: false + sourceComponent: Item { + anchors.fill: parent + Popup { + modal: true + visible: true + Overlay.modal: Rectangle { color: 'grey' } + } + } + } + } + + function test_popupWithOverlayInLoader() { // QTBUG-122915 + let loader = createTemporaryObject(popupWithOverlayInLoader, testCase) + verify(loader) + + let overlay = loader.Overlay.overlay + verify(overlay) + + loader.active = true + tryCompare(overlay, "visible", true) + + loader.active = false + tryCompare(overlay, "visible", false) + } } |