summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine/qstate.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-21 13:55:35 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-21 13:55:35 (GMT)
commitae6ab698ea739ac82cc6245742b58c7265ee82f8 (patch)
tree4597334d94b2150a12adb0fe835467425cd869da /src/corelib/statemachine/qstate.cpp
parent381e67f03155167cd9c1c0c3c4c3905196f287df (diff)
downloadQt-ae6ab698ea739ac82cc6245742b58c7265ee82f8.zip
Qt-ae6ab698ea739ac82cc6245742b58c7265ee82f8.tar.gz
Qt-ae6ab698ea739ac82cc6245742b58c7265ee82f8.tar.bz2
Have QState::addTransition(QAbstractTransition*) return the transition object
when it is added. Reduces the number of temporary variables you have to declare in your code since you can do things like: state->addTransition(new Transition())->addAnimation(new Animation()); Could also be used for error checking.
Diffstat (limited to 'src/corelib/statemachine/qstate.cpp')
-rw-r--r--src/corelib/statemachine/qstate.cpp9
1 files changed, 5 insertions, 4 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;
}
/*!