aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickstategroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/util/qquickstategroup.cpp')
-rw-r--r--src/quick/util/qquickstategroup.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp
index 2109aafc10..7cb3138618 100644
--- a/src/quick/util/qquickstategroup.cpp
+++ b/src/quick/util/qquickstategroup.cpp
@@ -376,7 +376,14 @@ bool QQuickStateGroupPrivate::updateAutoState()
QQuickState *state = states.at(ii);
if (state->isWhenKnown()) {
if (state->isNamed()) {
- if (state->when()) {
+ bool whenValue = state->when();
+ const QQmlProperty whenProp(state, QLatin1String("when"));
+ const auto potentialWhenBinding = QQmlPropertyPrivate::binding(whenProp);
+ // if there is a binding, the value in when might not be up-to-date at this point
+ // so we manually reevaluate the binding
+ if (auto abstractBinding = dynamic_cast<QQmlBinding *>(potentialWhenBinding))
+ whenValue = abstractBinding->evaluate().toBool();
+ if (whenValue) {
if (stateChangeDebug())
qWarning() << "Setting auto state due to expression";
if (currentState != state->name()) {