diff options
| author | Mitch Curtis <mitch.curtis@qt.io> | 2024-09-27 15:43:32 +0800 |
|---|---|---|
| committer | Mitch Curtis <mitch.curtis@qt.io> | 2024-10-02 08:56:53 +0800 |
| commit | 15b385af9f8e24e8c66588b55a3f7828d70d2c33 (patch) | |
| tree | f7436ce4fc3cec31989ad6b035f2722ff7d876f3 /src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp | |
| parent | fd1f8ea4e09cc0a3c007db462db35abbf92ef54d (diff) | |
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
Pick-to: 6.5 6.7 6.8
Change-Id: I220dfb78f00028e4a12a92fc14082006e1844002
Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp')
| -rw-r--r-- | src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp b/src/quickcontrols/basic/impl/qquickbasicbusyindicator.cpp index d6cceb2a56..f885c35c59 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: |
