[Qt-interest] eventTest() and parallel states in QStateMachine
Daniel Zollinger
dh.zollinger at googlemail.com
Thu Feb 10 20:36:30 CET 2011
Hi No'am, Hi Stephen,
On 02/07/2011 11:23 PM, noam.rosenthal at nokia.com wrote:
> This is indeed copied from the SCXML algorithm, which assumes that eventTest (or the SCXML equivalent of condition+eventName) has no consequences and thus running it more than once is, as well, inconsequential.
>
> I'd offer a patch to the SCXML algorithm:
>
> function selectTransitions(event):
> enabledTransitions = new OrderedSet()
> atomicStates = configuration.toList().filter(isAtomicState).sort(documentOrder)
> for state in atomicStates:
> if not isPreempted(state, enabledTransitions):
> loop: for s in [state].append(getProperAncestors(state, null)):
> for t in s.transition:
>
>
> + if !enabledTransitions.contains(t):
>
>
> if t.event and nameMatch(t.event, event.name<http://event.name>) and conditionMatch(t): enabledTransitions.add(t) break loop return enabledTransitions
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.
> 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, but
I'm not able to know if eventTest() has been invoked with the same
event, even though the changes are quite good if it's the same QEvent
pointer. ;-).
That's actually my workaround, I remember the QEvent pointer and the
result. Additionally I trigger a timer event to reset the remembered values.
Daniel
More information about the Qt-interest-old
mailing list