diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-06-17 09:25:30 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-06-17 09:30:39 (GMT) |
commit | 24580f35a58390b4177aef8edef1192dc05f8ac2 (patch) | |
tree | 5a5278707052d7e700d25b814d4153702ab0f5e7 | |
parent | fe59d3a82040e7202b4330a9da36fa4591e778c9 (diff) | |
download | Qt-24580f35a58390b4177aef8edef1192dc05f8ac2.zip Qt-24580f35a58390b4177aef8edef1192dc05f8ac2.tar.gz Qt-24580f35a58390b4177aef8edef1192dc05f8ac2.tar.bz2 |
perform all property assignments of initial state that's nested
If the machine's initial state is nested, a set of states will
be entered, and we need to do the property assignments of all
of them.
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qstatemachine/tst_qstatemachine.cpp | 30 |
2 files changed, 21 insertions, 13 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 04cce50..758bdbe 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1171,9 +1171,9 @@ void QStateMachinePrivate::_q_start() transitions.append(initialTransition); QEvent nullEvent(QEvent::None); executeTransitionContent(&nullEvent, transitions); - enterStates(&nullEvent, transitions); + QList<QAbstractState*> enteredStates = enterStates(&nullEvent, transitions); applyProperties(transitions, QList<QAbstractState*>() << start, - QList<QAbstractState*>() << initial); + enteredStates); delete start; #ifdef QSTATEMACHINE_DEBUG diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 9bccb97..cd0c71d 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -1269,25 +1269,33 @@ void tst_QStateMachine::assignProperty() s1->addTransition(s2); machine.setInitialState(s1); machine.start(); - QCoreApplication::processEvents(); - QCOMPARE(s1->objectName(), QString::fromLatin1("s1")); + QTRY_COMPARE(s1->objectName(), QString::fromLatin1("s1")); s1->assignProperty(s1, "objectName", "foo"); machine.start(); - QCoreApplication::processEvents(); - QCOMPARE(s1->objectName(), QString::fromLatin1("foo")); + QTRY_COMPARE(s1->objectName(), QString::fromLatin1("foo")); s1->assignProperty(s1, "noSuchProperty", 123); machine.start(); - QCoreApplication::processEvents(); - QCOMPARE(s1->objectName(), QString::fromLatin1("foo")); - QCOMPARE(s1->dynamicPropertyNames().size(), 1); + QTRY_COMPARE(s1->dynamicPropertyNames().size(), 1); QCOMPARE(s1->dynamicPropertyNames().at(0), QByteArray("noSuchProperty")); + QCOMPARE(s1->objectName(), QString::fromLatin1("foo")); - QSignalSpy polishedSpy(s1, SIGNAL(polished())); - machine.start(); - QCoreApplication::processEvents(); - QCOMPARE(polishedSpy.count(), 1); + { + QSignalSpy polishedSpy(s1, SIGNAL(polished())); + machine.start(); + QTRY_COMPARE(polishedSpy.count(), 1); + } + + // nested states + { + QState *s11 = new QState(s1); + QString str = QString::fromLatin1("set by nested state"); + s11->assignProperty(s11, "objectName", str); + s1->setInitialState(s11); + machine.start(); + QTRY_COMPARE(s11->objectName(), str); + } } void tst_QStateMachine::assignPropertyWithAnimation() |