QStateMachine: move QState::finished() emision into method.
By moving the code for QState::finished() emission into a virtual method which also receives the QFinalState that caused the emission, subclasses can hook in and do some extra processing. Change-Id: Id19947c09e196a0df4edb87d71b74b0600c78867 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
parent
56d091a4ea
commit
24b3d82eff
@ -610,10 +610,9 @@ void QStateMachinePrivate::enterStates(QEvent *event, const QList<QAbstractState
|
||||
QState *parent = s->parentState();
|
||||
if (parent) {
|
||||
if (parent != rootState()) {
|
||||
#ifdef QSTATEMACHINE_DEBUG
|
||||
qDebug() << q << ": emitting finished signal for" << parent;
|
||||
#endif
|
||||
QStatePrivate::get(parent)->emitFinished();
|
||||
QFinalState *finalState = qobject_cast<QFinalState *>(s);
|
||||
Q_ASSERT(finalState);
|
||||
emitStateFinished(parent, finalState);
|
||||
}
|
||||
QState *grandparent = parent->parentState();
|
||||
if (grandparent && isParallel(grandparent)) {
|
||||
@ -627,10 +626,9 @@ void QStateMachinePrivate::enterStates(QEvent *event, const QList<QAbstractState
|
||||
}
|
||||
}
|
||||
if (allChildStatesFinal && (grandparent != rootState())) {
|
||||
#ifdef QSTATEMACHINE_DEBUG
|
||||
qDebug() << q << ": emitting finished signal for" << grandparent;
|
||||
#endif
|
||||
QStatePrivate::get(grandparent)->emitFinished();
|
||||
QFinalState *finalState = qobject_cast<QFinalState *>(s);
|
||||
Q_ASSERT(finalState);
|
||||
emitStateFinished(grandparent, finalState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1619,6 +1617,18 @@ void QStateMachinePrivate::cancelAllDelayedEvents()
|
||||
delayedEvents.clear();
|
||||
}
|
||||
|
||||
void QStateMachinePrivate::emitStateFinished(QState *forState, QFinalState *guiltyState)
|
||||
{
|
||||
Q_UNUSED(guiltyState);
|
||||
Q_ASSERT(guiltyState);
|
||||
|
||||
#ifdef QSTATEMACHINE_DEBUG
|
||||
qDebug() << q << ": emitting finished signal for" << forState;
|
||||
#endif
|
||||
|
||||
QStatePrivate::get(forState)->emitFinished();
|
||||
}
|
||||
|
||||
namespace _QStateMachine_Internal{
|
||||
|
||||
class GoToStateTransition : public QAbstractTransition
|
||||
|
@ -188,6 +188,8 @@ public:
|
||||
void processEvents(EventProcessingMode processingMode);
|
||||
void cancelAllDelayedEvents();
|
||||
|
||||
virtual void emitStateFinished(QState *forState, QFinalState *guiltyState);
|
||||
|
||||
#ifndef QT_NO_PROPERTIES
|
||||
class RestorableId {
|
||||
QPointer<QObject> guard;
|
||||
|
Loading…
x
Reference in New Issue
Block a user