From 3351a7215ccdc548b33770b8e1c120d81c323443 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 27 Sep 2024 15:43:32 +0800 Subject: Fix BusyIndicator being hidden when running is changed quickly If running is set to false and then true within a short period, BusyIndicatorImpl's OpacityAnimator cancels the 1 => 0 animation (which was for running being set to false), setting opacity to 0 and hence visible to false. This happens _after_ setRunning(true) was called, because the properties were set synchronously but the animation is asynchronous. To account for this situation, we only hide ourselves if we're not running by storing and checking our running state. Fixes: QTBUG-85860 Change-Id: I220dfb78f00028e4a12a92fc14082006e1844002 Reviewed-by: Doris Verria (cherry picked from commit 15b385af9f8e24e8c66588b55a3f7828d70d2c33) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 52016f3ae62637c18513ec0e9ad27fb916b0080c) --- src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp') diff --git a/src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp b/src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp index 7733672a24..d013967e5f 100644 --- a/src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp +++ b/src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp @@ -145,8 +145,11 @@ bool QQuickBasicBusyIndicator::isRunning() const void QQuickBasicBusyIndicator::setRunning(bool running) { - if (running) + m_running = running; + + if (m_running) setVisible(true); + // Don't set visible to false if not running, because we use an opacity animation (in QML) to hide ourselves. } int QQuickBasicBusyIndicator::elapsed() const @@ -159,7 +162,12 @@ void QQuickBasicBusyIndicator::itemChange(QQuickItem::ItemChange change, const Q QQuickItem::itemChange(change, data); switch (change) { case ItemOpacityHasChanged: - if (qFuzzyIsNull(data.realValue)) + // If running is set to false and then true within a short period (QTBUG-85860), our + // OpacityAnimator cancels the 1 => 0 animation (which was for running being set to false), + // setting opacity to 0 and hence visible to false. This happens _after_ setRunning(true) + // was called, because the properties were set synchronously but the animation is + // asynchronous. To account for this situation, we only hide ourselves if we're not running. + if (qFuzzyIsNull(data.realValue) && !m_running) setVisible(false); break; case ItemVisibleHasChanged: -- cgit v1.2.3