summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-08-30 16:00:40 +0200
committerIvan Solovev <ivan.solovev@qt.io>2023-09-18 18:24:37 +0200
commitab9f5a9a0b13c33e103d159a40869a69a9583899 (patch)
tree77d37bed045d332eda2315f6334a3f2b5a01ea5a /src/corelib/animation
parent4583d808ea50beb8da9302f34eacfc1e9a2ed907 (diff)
QAbstractAnimation: avoid spurious dependencies on the state property
The state property is read-only, meaning that it can only be modified from the class internals. At the same time, the public start(), stop(), pause(), and resume() methods, as well as a private setState() method can be called from other property setters, thus creating an unwanted dependency on state. Fix it by using valueBypassingBindings() when reading the state. Task-number: QTBUG-116346 Pick-to: 6.6 6.5 Change-Id: I404cd2141ea52b8ffed5edbb4261a535cd329ec2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/animation')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index c32053db82..e9845b0e17 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -901,13 +901,13 @@ QAbstractAnimationPrivate::~QAbstractAnimationPrivate() { }
void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
{
Q_Q(QAbstractAnimation);
- if (state == newState)
+ const QAbstractAnimation::State oldState = state.valueBypassingBindings();
+ if (oldState == newState)
return;
if (loopCount == 0)
return;
- QAbstractAnimation::State oldState = state;
int oldCurrentTime = currentTime;
int oldCurrentLoop = currentLoop;
QAbstractAnimation::Direction oldDirection = direction;
@@ -941,13 +941,15 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
}
q->updateState(newState, oldState);
- if (!guard || newState != state) //this is to be safe if updateState changes the state
+ //this is to be safe if updateState changes the state
+ if (!guard || newState != state.valueBypassingBindings())
return;
// Notify state change
state.notify();
emit q->stateChanged(newState, oldState);
- if (!guard || newState != state) //this is to be safe if updateState changes the state
+ //this is to be safe if updateState changes the state
+ if (!guard || newState != state.valueBypassingBindings())
return;
switch (state) {
@@ -1377,7 +1379,7 @@ void QAbstractAnimation::setCurrentTime(int msecs)
void QAbstractAnimation::start(DeletionPolicy policy)
{
Q_D(QAbstractAnimation);
- if (d->state == Running)
+ if (d->state.valueBypassingBindings() == Running)
return;
d->deleteWhenStopped = policy;
d->setState(Running);
@@ -1397,7 +1399,7 @@ void QAbstractAnimation::stop()
{
Q_D(QAbstractAnimation);
- if (d->state == Stopped)
+ if (d->state.valueBypassingBindings() == Stopped)
return;
d->setState(Stopped);
@@ -1413,7 +1415,7 @@ void QAbstractAnimation::stop()
void QAbstractAnimation::pause()
{
Q_D(QAbstractAnimation);
- if (d->state == Stopped) {
+ if (d->state.valueBypassingBindings() == Stopped) {
qWarning("QAbstractAnimation::pause: Cannot pause a stopped animation");
return;
}
@@ -1431,7 +1433,7 @@ void QAbstractAnimation::pause()
void QAbstractAnimation::resume()
{
Q_D(QAbstractAnimation);
- if (d->state != Paused) {
+ if (d->state.valueBypassingBindings() != Paused) {
qWarning("QAbstractAnimation::resume: "
"Cannot resume an animation that is not paused");
return;