[Qt-interest] eventTest() and parallel states in QStateMachine

noam.rosenthal at nokia.com noam.rosenthal at nokia.com
Thu Feb 10 21:56:03 CET 2011


________________________________________
From: ext Daniel Zollinger [dh.zollinger at googlemail.com]
> I don't think this would work. If eventTest() returns false at the first
> invocation, the transition wouldn't be in enabledTransitions and
> eventTest() would be invoked a second time and thus the dialog.

Right. In that case there's nothing much you can do on the algorithm level.

> Architecturally, I advise you to put less "beef" inside eventTest and instead give your MapSelect dialog its own state, which would make this problem irrelevant (as the transition would happen only
once, even if tested more than once).

> I actually don't exactly understand what you propose.
> I have to return false in eventTest() when the user presses cancel, 

That is if you design your statechart in the way you describe, which counts on the assumption that eventTest would be called only once, that is apparently not something you can count on :)

What I suggest is this.

Let's say this is your statechart:


Machine (MapSelect[isDialogAccepted()] -> Map)
    Map
       ..
       ..
    Overlay
       ..
       ..

Instead I would propose the following:


Machine (MapSelect-> MapSelectionDialog)
    Map (Parallel)
       ..
       ..
    Overlay
       ..
       ..
     MachineHistory (QHistoryState, deep)
     MapSelectionDialog
         onEntry: showDialog
         onExit: hideDialog
         [reject] -> MachineHistory
         [accept] -> Map

Your dialog would have its own state rather than be something tha's get sequentially called inside eventTest.

In the statechart concept behind SCXML (and thus behind QStateMachine), a dialog would get its own state. and the algorithm is built to contain that concept.

Otherwise, your workaround is your best bet as I don't see how the algorithm could be fixed :)
No'am




More information about the Qt-interest-old mailing list