diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2019-04-16 13:30:31 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-16 16:51:42 +0200 |
commit | cfdbfcebbda5f26b89c70df6b191b17ef242e9d7 (patch) | |
tree | a449821770043dcb57a5efb54384565ff98cbf3f /tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp | |
parent | d7afd8bb381956bcddfbda0ec929251da8048598 (diff) |
QStateMachine: handle parallel child mode for state machines
Setting the childMode property to ParallelStates will result in an
invalid state machine. This is never checked (worse, we explicitly
allow it and have a constructor to set it), but it results in
findLCCA failing, which then results in a failing assert or crash.
This fix in this patch is to handle this case separately. The proper
fix would be to remove completely the ability to set the childMode
on a QStateMachine, but that will have to wait until Qt6.
Fixes: QTBUG-49975
Change-Id: I43692309c4d438ee1a9bc55fa4f65f8bce8e0a59
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp')
-rw-r--r-- | tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 55a672aae1..0312cff5da 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -336,7 +336,9 @@ void tst_QStateMachine::transitionToRootState() TEST_ACTIVE_CHANGED(initialState, 1); machine.postEvent(new QEvent(QEvent::User)); - QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 'initial'"); + QTest::ignoreMessage(QtWarningMsg, + "Unrecoverable error detected in running state machine: " + "Child mode of state machine 'machine' is not 'ExclusiveStates'!"); QCoreApplication::processEvents(); QVERIFY(machine.configuration().isEmpty()); QVERIFY(!machine.isRunning()); @@ -1061,7 +1063,8 @@ void tst_QStateMachine::transitionToStateNotInGraph() initialState->addTransition(&independentState); machine.start(); - QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 'initialState'"); + QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: " + "Child mode of state machine '' is not 'ExclusiveStates'!"); QCoreApplication::processEvents(); QCOMPARE(machine.isRunning(), false); @@ -2099,6 +2102,8 @@ void tst_QStateMachine::parallelRootState() QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.start(); + QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: " + "Child mode of state machine '' is not 'ExclusiveStates'!"); QTRY_COMPARE(startedSpy.count(), 1); QCOMPARE(machine.configuration().size(), 4); QVERIFY(machine.configuration().contains(s1)); @@ -3310,14 +3315,15 @@ void tst_QStateMachine::targetStateWithNoParent() QVERIFY(runningSpy.isValid()); machine.start(); - QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 's1'"); + QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: " + "Child mode of state machine '' is not 'ExclusiveStates'!"); TEST_ACTIVE_CHANGED(s1, 2); QTRY_COMPARE(startedSpy.count(), 1); QCOMPARE(machine.isRunning(), false); QCOMPARE(stoppedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); TEST_RUNNING_CHANGED_STARTED_STOPPED; - QCOMPARE(machine.error(), QStateMachine::NoCommonAncestorForTransitionError); + QCOMPARE(machine.error(), QStateMachine::StateMachineChildModeSetToParallelError); } void tst_QStateMachine::targetStateDeleted() |