Add QStateMachine constructor that takes a ChildMode
Back when QStateMachine was changed to inherit QState, this
constructor was conveniently left out because setting the state
machine (root state) to be a parallel state group didn't actually
work. But as of commit d281aa6936
,
it does work, so add the missing constructor.
Task-number: QTBUG-15430
Change-Id: I68c599baa0ef1bfc869195140cf5daf645e75b8b
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
This commit is contained in:
parent
034b5fd02e
commit
0b66f723f0
@ -1917,6 +1917,20 @@ QStateMachine::QStateMachine(QObject *parent)
|
||||
setParent(parent);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.0
|
||||
|
||||
Constructs a new state machine with the given \a childMode
|
||||
and \a parent.
|
||||
*/
|
||||
QStateMachine::QStateMachine(QState::ChildMode childMode, QObject *parent)
|
||||
: QState(*new QStateMachinePrivate, /*parentState=*/0)
|
||||
{
|
||||
Q_D(QStateMachine);
|
||||
d->childMode = childMode;
|
||||
setParent(parent); // See comment in constructor above
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
|
@ -120,6 +120,7 @@ public:
|
||||
};
|
||||
|
||||
explicit QStateMachine(QObject *parent = 0);
|
||||
QStateMachine(QState::ChildMode childMode, QObject *parent = 0);
|
||||
~QStateMachine();
|
||||
|
||||
void addState(QAbstractState *state);
|
||||
|
@ -210,6 +210,7 @@ private slots:
|
||||
void createEventTransitionWhenRunning();
|
||||
void signalTransitionSenderInDifferentThread();
|
||||
void signalTransitionRegistrationThreadSafety();
|
||||
void childModeConstructor();
|
||||
};
|
||||
|
||||
class TestState : public QState
|
||||
@ -4934,5 +4935,46 @@ void tst_QStateMachine::signalTransitionRegistrationThreadSafety()
|
||||
QTRY_VERIFY(thread.wait());
|
||||
}
|
||||
|
||||
void tst_QStateMachine::childModeConstructor()
|
||||
{
|
||||
{
|
||||
QStateMachine machine(QState::ExclusiveStates);
|
||||
QCOMPARE(machine.childMode(), QState::ExclusiveStates);
|
||||
QVERIFY(machine.parent() == 0);
|
||||
QVERIFY(machine.parentState() == 0);
|
||||
}
|
||||
{
|
||||
QStateMachine machine(QState::ParallelStates);
|
||||
QCOMPARE(machine.childMode(), QState::ParallelStates);
|
||||
QVERIFY(machine.parent() == 0);
|
||||
QVERIFY(machine.parentState() == 0);
|
||||
}
|
||||
{
|
||||
QStateMachine machine(QState::ExclusiveStates, this);
|
||||
QCOMPARE(machine.childMode(), QState::ExclusiveStates);
|
||||
QCOMPARE(machine.parent(), static_cast<QObject *>(this));
|
||||
QVERIFY(machine.parentState() == 0);
|
||||
}
|
||||
{
|
||||
QStateMachine machine(QState::ParallelStates, this);
|
||||
QCOMPARE(machine.childMode(), QState::ParallelStates);
|
||||
QCOMPARE(machine.parent(), static_cast<QObject *>(this));
|
||||
QVERIFY(machine.parentState() == 0);
|
||||
}
|
||||
QState state;
|
||||
{
|
||||
QStateMachine machine(QState::ExclusiveStates, &state);
|
||||
QCOMPARE(machine.childMode(), QState::ExclusiveStates);
|
||||
QCOMPARE(machine.parent(), static_cast<QObject *>(&state));
|
||||
QCOMPARE(machine.parentState(), &state);
|
||||
}
|
||||
{
|
||||
QStateMachine machine(QState::ParallelStates, &state);
|
||||
QCOMPARE(machine.childMode(), QState::ParallelStates);
|
||||
QCOMPARE(machine.parent(), static_cast<QObject *>(&state));
|
||||
QCOMPARE(machine.parentState(), &state);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QStateMachine)
|
||||
#include "tst_qstatemachine.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user