summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-11-24 04:19:46 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-11-24 04:19:46 (GMT)
commite3ec86e388a35b850573b8fd8b58c93113bb8bd3 (patch)
tree9ef24f9ba783fa9c46ec3841dc60a99fb3c9649c /src/declarative
parent3d2b0d622908fe2c89ac1c2d5a5cb7ed96a24b6a (diff)
downloadQt-e3ec86e388a35b850573b8fd8b58c93113bb8bd3.zip
Qt-e3ec86e388a35b850573b8fd8b58c93113bb8bd3.tar.gz
Qt-e3ec86e388a35b850573b8fd8b58c93113bb8bd3.tar.bz2
Prevent state changes within PropertyChanges.
Task-number: QT-2358
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/util/qmlstategroup.cpp19
-rw-r--r--src/declarative/util/qmltransitionmanager.cpp5
2 files changed, 16 insertions, 8 deletions
diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp
index d6ce191..4dfa34a 100644
--- a/src/declarative/util/qmlstategroup.cpp
+++ b/src/declarative/util/qmlstategroup.cpp
@@ -42,6 +42,7 @@
#include "private/qobject_p.h"
#include "qmlstategroup_p.h"
#include "qmltransition_p.h"
+#include "qmlstate_p_p.h"
#include <qmlbinding.h>
#include <QtCore/qdebug.h>
#include <private/qmlglobal_p.h>
@@ -57,7 +58,8 @@ class QmlStateGroupPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QmlStateGroup)
public:
QmlStateGroupPrivate(QmlStateGroup *p)
- : nullState(0), states(p), componentComplete(true), ignoreTrans(false) {}
+ : nullState(0), states(p), componentComplete(true),
+ ignoreTrans(false), applyingState(false) {}
QString currentState;
QmlState *nullState;
@@ -78,6 +80,7 @@ public:
QmlConcreteList<QmlTransition *> transitions;
bool componentComplete;
bool ignoreTrans;
+ bool applyingState;
QmlTransition *findTransition(const QString &from, const QString &to);
void setCurrentStateInternal(const QString &state, bool = false);
@@ -212,9 +215,6 @@ void QmlStateGroup::setState(const QString &state)
return;
d->setCurrentStateInternal(state);
-
- d->currentState = state;
- emit stateChanged(d->currentState);
}
void QmlStateGroup::classBegin()
@@ -334,6 +334,13 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state,
if (!componentComplete)
return;
+ if (applyingState) {
+ qWarning() << "Can't apply a state change as part of a state definition.";
+ return;
+ }
+
+ applyingState = true;
+
QmlTransition *transition = (ignoreTrans || ignoreTrans) ? 0 : findTransition(currentState, state);
if (stateChangeDebug()) {
qWarning() << this << "Changing state. From" << currentState << ". To" << state;
@@ -353,6 +360,7 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state,
}
currentState = state;
+ emit q->stateChanged(currentState);
QmlState *newState = 0;
for (int ii = 0; ii < states.count(); ++ii) {
@@ -369,6 +377,9 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state,
}
newState->apply(q, transition, oldState);
+ applyingState = false;
+ if (!transition)
+ static_cast<QmlStatePrivate*>(QObjectPrivate::get(newState))->complete();
}
QmlState *QmlStateGroup::findState(const QString &name) const
diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp
index ba726db..1a164c7 100644
--- a/src/declarative/util/qmltransitionmanager.cpp
+++ b/src/declarative/util/qmltransitionmanager.cpp
@@ -236,11 +236,8 @@ void QmlTransitionManager::transition(const QList<Action> &list,
action.property.write(action.toValue);
}
}
- if (!transition) {
+ if (!transition)
d->applyBindings();
- if (d->state)
- static_cast<QmlStatePrivate*>(QObjectPrivate::get(d->state))->complete();
- }
}
void QmlTransitionManager::cancel()