[Qt-interest] unable to use more than 1 transition added to a state (QT StateMachine Framework)
Sean Harmer
sean.harmer at maps-technology.com
Thu Mar 18 10:37:38 CET 2010
Hi,
On Wednesday 17 March 2010 08:56:01 Mandeep Sandhu wrote:
> On further debugging this problem I found that the issue is because of
> attaching the same transition to more than 1 state.
>
> Can't a transition be attached to more than 1 state?
>
> Eg. If i define my transition as "On event E1, move to State S1"
>
> I attach this transition to S3 and S6...now if an event E1 occurs
> while the state machine is in S3 or S6, it should transition to S1.
> Correct?
>
> Or is this a bug in the state machine framework?
This is not a bug in the SM framework. You need to use multiple instances of
your specialised guarded transition class. The reason is because each instance
of your transition class knows about its source and destination states. If you
add a transition to a state and then add the same instance to another state,
then its internal source and/or destination state pointers will get
overwritten with the new ones. Hence there will be no transition between the
original source and destination states.
Cheers,
Sean
>
> Thanks,
> -mandeep
>
> On Tue, Mar 16, 2010 at 7:39 PM, Mandeep Sandhu
>
> <mandeepsandhu.chd at gmail.com> wrote:
> > Hi All,
> >
> > I'm implementing my FSM which reacts to User QEvents (event type >
> > QEvent::User). An external app does postEvent(QEvent) to the state
> > machine.
> >
> > As part of that I'm implementing my own custom transition which
> > extends QtAbstractTransition and reimplements the eventTest() method
> > as shown here:
> >
> > http://doc.qt.nokia.com/4.6/statemachine-api.html#events-transitions-and-
> > guards
> >
> > However, if I add more than one such transition to my state (say to
> > S3) then the statemachine is unable to find any transition and remains
> > stuck at S3. I've seen the code in example/eventtransitions where they
> > add TWO QEventTransition's to a state and it seems to be working fine.
> > I have set valid target states to these transitions.
> >
> > Note that if add only ONE transition, then it works fine, as in on the
> > correct event I transition to the next state.
> >
> > Any clues as howto further debug this issue?
> >
> > thanks,
> > -mandeep
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list