diff options
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 14 | ||||
-rw-r--r-- | src/corelib/statemachine/qstatemachine_p.h | 1 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 25c9343943..bea6822ecc 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1845,6 +1845,8 @@ void QStateMachinePrivate::_q_start() registerMultiThreadedSignalTransitions(); + startupHook(); + #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": starting"; #endif @@ -2114,6 +2116,10 @@ void QStateMachinePrivate::emitStateFinished(QState *forState, QFinalState *guil QStatePrivate::get(forState)->emitFinished(); } +void QStateMachinePrivate::startupHook() +{ +} + /* This function is called when the state machine is performing no microstep because no transition is enabled (i.e. an event is ignored). @@ -2726,14 +2732,18 @@ void QStateMachine::setRunning(bool running) event queue. Events are processed in the order posted. The state machine takes ownership of the event and deletes it once it has been processed. - You can only post events when the state machine is running. + You can only post events when the state machine is running or when it is starting up. \sa postDelayedEvent() */ void QStateMachine::postEvent(QEvent *event, EventPriority priority) { Q_D(QStateMachine); - if (d->state != QStateMachinePrivate::Running) { + switch (d->state) { + case QStateMachinePrivate::Running: + case QStateMachinePrivate::Starting: + break; + default: qWarning("QStateMachine::postEvent: cannot post event when the state machine is not running"); return; } diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 5584bc91ab..5db6489fa9 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -202,6 +202,7 @@ public: void cancelAllDelayedEvents(); virtual void emitStateFinished(QState *forState, QFinalState *guiltyState); + virtual void startupHook(); #ifndef QT_NO_PROPERTIES class RestorableId { |