diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-05-12 16:38:32 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-05-12 16:38:32 (GMT) |
commit | 09d1e6ee7d93c9fb658b2be5fe49698bf3faa0d6 (patch) | |
tree | 2e68a3b01279934464acf98dd774b90659573dc6 /tests/auto/qstatemachine | |
parent | 3db6f6234eb36ec4b3d6e14dc48917762653cbd7 (diff) | |
download | Qt-09d1e6ee7d93c9fb658b2be5fe49698bf3faa0d6.zip Qt-09d1e6ee7d93c9fb658b2be5fe49698bf3faa0d6.tar.gz Qt-09d1e6ee7d93c9fb658b2be5fe49698bf3faa0d6.tar.bz2 |
correctly handle multiple signal transitions for same (object,signal)
The signal was not disconnected at the right time. We now store the
number of active signal transitions for a particular (object,signal)
and only disconnect when the count drops to zero.
Diffstat (limited to 'tests/auto/qstatemachine')
-rw-r--r-- | tests/auto/qstatemachine/tst_qstatemachine.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 9058cb6..3f94ad9 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -1711,6 +1711,51 @@ void tst_QStateMachine::signalTransitions() QTRY_COMPARE(finishedSpy.count(), 1); } + // Multiple transitions for same (object,signal) + { + QStateMachine machine; + SignalEmitter emitter; + QState *s0 = new QState(machine.rootState()); + QState *s1 = new QState(machine.rootState()); + QSignalTransition *t0 = s0->addTransition(&emitter, SIGNAL(signalWithNoArg()), s1); + QSignalTransition *t1 = s1->addTransition(&emitter, SIGNAL(signalWithNoArg()), s0); + + QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + machine.setInitialState(s0); + machine.start(); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s0)); + + emitter.emitSignalWithNoArg(); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + s0->removeTransition(t0); + emitter.emitSignalWithNoArg(); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s0)); + + emitter.emitSignalWithNoArg(); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s0)); + + s1->removeTransition(t1); + emitter.emitSignalWithNoArg(); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s0)); + + s0->addTransition(t0); + s1->addTransition(t1); + emitter.emitSignalWithNoArg(); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + } } void tst_QStateMachine::eventTransitions() |