[Qt-interest] Fwd: Re: Qt state machine: problem while queuing multiple events

Peter Kuemmel syntheticpp at gmx.net
Fri Jun 24 13:26:34 CEST 2011


-------- Original-Nachricht --------
Datum: Fri, 24 Jun 2011 13:08:07 +0200
Von: "Peter Kuemmel" <syntheticpp at gmx.net>
An: Mandeep Sandhu <mandeepsandhu.chd at gmail.com>
Betreff: Re: [Qt-interest] Qt state machine: problem while queuing multiple events

> Hi Peter,
> 
> > So the decision if a e3 event should trigger the transition from S2 to
> S3
> > or S3 to S2 is NOT done by the state machine? There should be no
> translation,
> > the decision should be part of the state machine.
> 
> The SM does make the decision. Rather I have custom guarded
> transitions that make the decision on when to trigger a SM transitions
> (as Sean pointed out in his last mail).
> 
> >
> > Doesn't it work if a S3->S2 transition tests if the event is e3 and only
> > then return true, also a S2->S1 which tests on e2. Then you could post
> > the events without any translation to the machine and the machine knows
> > what to do with the events. For instance if you are in S2 and it comes
> > an e3 event it always makes a transition to S3 regardless of how many e3
> > events are in the queue, or were in the queue.
> 
> Thats how the simple SM i pointed above is connected. Rather all
> 'forward' transitions are taking place the way you described.
> 
> But I have a requirement, which says that on receiving e3 when in S3,
> go back to S2. Similar requirement is to go to S1 when receiving e2 in
> S2.

Hi Mandeep,

I don't understand why you could not add also a transition S3->S2 which 
tests on e3.

> 
> The problem is that when in S3, I can receive more than 1 key presses
> in quick succession, even before the event posted to the SM gets a
> chance to be processed. This is because of the way Qt's event loop is
> configured to read 'spontaneous' (key press etc) and 'posted' (post
> event to SM event loop) events.
> 
> So, because of this there are TWO 'back' events posted to the SM's
> event loop waiting to be processed and when it does process them, it
> transitions to S2 and then to S1 (since 'back' was a valid event in
> both states).

My idea was not to have 'back' events at all in the queue, only e1,e2,e3,...

But maybe not important, seems you've found a solution.

Peter

> 
> The only valid solution (other than putting hacks in SM to NOT queue
> more than 1 event), seems to be to have different events for S3->S2
> and S2->S1 transitions.
> 
> Hope that explains it.
> 
> -mandeep

-- 
NEU: FreePhone - kostenlos mobil telefonieren!			
Jetzt informieren: http://www.gmx.net/de/go/freephone


-- 
NEU: FreePhone - kostenlos mobil telefonieren!			
Jetzt informieren: http://www.gmx.net/de/go/freephone



More information about the Qt-interest-old mailing list