summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qmlstategroup.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-01-12 01:13:55 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-01-12 01:13:55 (GMT)
commit20098f931b6c19f6caf1fc1fc23297d14cb9e707 (patch)
tree50585cdf7c550708f4e134b42a3af4ed0bc588d6 /src/declarative/util/qmlstategroup.cpp
parentc0c2352a287348469617811985d773ec4c3d1875 (diff)
downloadQt-20098f931b6c19f6caf1fc1fc23297d14cb9e707.zip
Qt-20098f931b6c19f6caf1fc1fc23297d14cb9e707.tar.gz
Qt-20098f931b6c19f6caf1fc1fc23297d14cb9e707.tar.bz2
Don't double enter states at startup.
QT-2697
Diffstat (limited to 'src/declarative/util/qmlstategroup.cpp')
-rw-r--r--src/declarative/util/qmlstategroup.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp
index 373d457..d4db2b9 100644
--- a/src/declarative/util/qmlstategroup.cpp
+++ b/src/declarative/util/qmlstategroup.cpp
@@ -88,7 +88,7 @@ public:
QmlTransition *findTransition(const QString &from, const QString &to);
void setCurrentStateInternal(const QString &state, bool = false);
- void updateAutoState();
+ bool updateAutoState();
};
/*!
@@ -231,25 +231,30 @@ void QmlStateGroup::componentComplete()
{
Q_D(QmlStateGroup);
d->componentComplete = true;
- d->updateAutoState();
- if (!d->currentState.isEmpty()) {
+
+ if (d->updateAutoState()) {
+ return;
+ } else if (!d->currentState.isEmpty()) {
QString cs = d->currentState;
d->currentState = QString();
d->setCurrentStateInternal(cs, true);
}
}
-void QmlStateGroup::updateAutoState()
+/*!
+ Returns true if the state was changed, otherwise false.
+*/
+bool QmlStateGroup::updateAutoState()
{
Q_D(QmlStateGroup);
- d->updateAutoState();
+ return d->updateAutoState();
}
-void QmlStateGroupPrivate::updateAutoState()
+bool QmlStateGroupPrivate::updateAutoState()
{
Q_Q(QmlStateGroup);
if (!componentComplete)
- return;
+ return false;
bool revert = false;
for (int ii = 0; ii < states.count(); ++ii) {
@@ -260,16 +265,25 @@ void QmlStateGroupPrivate::updateAutoState()
if (stateChangeDebug())
qWarning() << "Setting auto state due to:"
<< state->when()->expression();
- q->setState(state->name());
- return;
+ if (currentState != state->name()) {
+ q->setState(state->name());
+ return true;
+ } else {
+ return false;
+ }
} else if (state->name() == currentState) {
revert = true;
}
}
}
}
- if (revert)
+ if (revert) {
+ bool rv = currentState != QString();
q->setState(QString());
+ return rv;
+ } else {
+ return false;
+ }
}
QmlTransition *QmlStateGroupPrivate::findTransition(const QString &from, const QString &to)