[Development] Semantics of QState when state machine execution is stopped

Kevin Funk kevin.funk at kdab.com
Thu Jul 17 14:44:56 CEST 2014


On Sunday 06 July 2014 23:55:14 BogDan wrote:
> [..]
> 
> >> I presume that changing the semantics here (i.e. triggering
> >> QAbstractState::onExited when the machine is stopped) isn't appropriate,
> >> as it may break existing applications, but I'm not exactly sure.
> >
> >I think it would be far less risk of breaking existing applications to
> >simply set active = false on all active states when the machine is
> >stopped.  Does that not address the problematic use case(s)?
> It will be inconsistent, because when you stop a state machine the state
> will become inactive but it remains entered ... activeChanged entered and
> exited signals are describing the same thing: if the current state is
> active or not. But when the state machine is stopped any active state can't
> remain active. So, IMHO the fact that exited signal is not emitted when a
> state machine is stopped is a bug and should be fixed.
> 
> Yours,
> BogDan.

After some discussion between Brett, me and Bogdan, we concluded that the 
following approach is probably the best:

- Don't change the semantics of QSM
  (i.e. don't trigger QAbstractState::onExited when the machine is stopped)
- QAbstractState::active property stays 'true' in case the machine is stopped
- QAbstractState::active is set to false as soon as the machine is restarted

This behavior mirrors the semantics of QStateMachine::configuration. After the 
machine has stopped, QStateMachine::configuration still contains the set of 
last active states. Only when restarting the machine, the configuration is 
cleared.

Plus, this approach cannot break existing applications.

Review-request updated: https://codereview.qt-project.org/#/c/88596/

Greets

-- 
Qt Developer Days 2014 • October 6 - 8 at BCC, Berlin • Save the dates!

Kevin Funk | kevin.funk at kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel. Germany +49-30-521325470, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions



More information about the Development mailing list