[Qt-interest] was event accepted by state machine?
Maxim Kirillov
max630 at gmail.com
Tue Feb 1 16:22:27 CET 2011
On Tue, Feb 1, 2011 at 4:48 PM, K. Frank <kfrank29.c at gmail.com> wrote:
> On Tue, Feb 1, 2011 at 7:48 AM, Maxim Kirillov <max630 at gmail.com> wrote:
>> Let's say I have a QStateMachine. For some event there are
>> states that have transition defined for that event and
>> states that does not listen for that event.
>>
>> I would like to trigger the event and know if it was
>> accepted.
>
> Is this for debugging or diagnostic purposes?
>
> If not for some kind of debugging, you probably don't want to do
> this. The producer of the event shouldn't need to know or care
> what, if anything, the state machine does with its event. That's
> the concern of the state machine.
Currently my purpose is to make a synchronous interface to
a system managed by the state machine. So the calling
function posts an event and waits for response signal. If
the event does not cause a state change, then it will
probably wait forever.
....
> I think instead you could have the states that are
> supposed to ignore the event make transitions back to
> themselves (rather than to a fake "bad" state). You could
> have an action associated with the transition-to-self that
> logs some kind of message, "event ignored."
I see. Thank you, looks like is does what I need.
Another option which works is to set the transition to self
on the whole state machine. Not sure if it is correct, need
to check in the docs.
--
Max
More information about the Qt-interest-old
mailing list