diff options
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r-- | src/corelib/statemachine/qstate.cpp | 9 | ||||
-rw-r--r-- | src/corelib/statemachine/qstate.h | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index e3da1c5..abd7379 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -247,28 +247,29 @@ void QState::setErrorState(QAbstractState *state) Adds the given \a transition. The transition has this state as the source. This state takes ownership of the transition. */ -void QState::addTransition(QAbstractTransition *transition) +QAbstractTransition *QState::addTransition(QAbstractTransition *transition) { Q_D(QState); if (!transition) { qWarning("QState::addTransition: cannot add null transition"); - return; + return 0; } const QList<QAbstractState*> &targets = QAbstractTransitionPrivate::get(transition)->targetStates; for (int i = 0; i < targets.size(); ++i) { QAbstractState *t = targets.at(i); if (!t) { qWarning("QState::addTransition: cannot add transition to null state"); - return; + return 0; } if ((QAbstractStatePrivate::get(t)->machine() != d->machine()) && QAbstractStatePrivate::get(t)->machine() && d->machine()) { qWarning("QState::addTransition: cannot add transition " "to a state in a different state machine"); - return; + return 0; } } transition->setParent(this); + return transition; } /*! diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h index 4c86e02..1ec0896 100644 --- a/src/corelib/statemachine/qstate.h +++ b/src/corelib/statemachine/qstate.h @@ -81,7 +81,7 @@ public: QAbstractState *errorState() const; void setErrorState(QAbstractState *state); - void addTransition(QAbstractTransition *transition); + QAbstractTransition *addTransition(QAbstractTransition *transition); QSignalTransition *addTransition(QObject *sender, const char *signal, QAbstractState *target); QAbstractTransition *addTransition(QAbstractState *target); QStateFinishedTransition *addFinishedTransition(QAbstractState *target); |