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

Kevin Funk kevin.funk at kdab.com
Wed Jul 2 16:11:36 CEST 2014


Hey there,

We are currently making the QStateMachine QML-ready by amending all the QSM-
related classes (derived from QAbstractState, QAbstractTransition) and adding 
Q_PROPERTYs macro where needed. You can see a list of already merged changes 
here [1].

All of this work in qtbase is supposed to help making the QStateMachine API 
QML ready. Maybe you remember the request for the 'QQSM' sandbox area a few 
months ago [2] and the short QtCS session held by Brett and myself.

Now to the problem:
One change introduces a QAbstractState::active property [3], which is 
important for binding QML properties to the activeness of individual states. 
This, however, reveals some issues regarding QSM semantics:

We set active to true in case we enter the state (QAbstractState::onEntered) 
and set it to false when leaving it again (via QAbstractState::onExited). 
Easy. When *stopping* the QSM instance, QAbstractState::onExited is never 
called, though. Hence, the after that, states may still be active, which is 
not what we want.

Now the big question: Is this a bug or is it intended? From my gut feeling I 
think there should be always a matching pair of onEntered/onExited calls. 
Right now, we can end up getting consecutive calls to 
QAbstractState::onEntered (when the QSM is restarted while this state was 
active).

The SCXML spec seems to agree here, if I interpret it correctly. Cf. [4], 
"procedure exitInterpreter()": "The purpose of this procedure is to exit the 
current SCXML process by exiting all active states." I'd consider exiting the 
interpreter equal to stopping a QSM instance.

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.

Proposed change in semantics is here:
https://codereview.qt-project.org/#/c/88905/

Opinions?

[1]
https://codereview.qt-project.org/#/c/88031/ (merged)
https://codereview.qt-project.org/#/c/88032/ (merged)
https://codereview.qt-project.org/#/c/88594/ (merged)
https://codereview.qt-project.org/#/c/88595/ (merged)
[2] 
http://lists.qt-project.org/pipermail/development/2014-May/017141.html
[3] 
https://codereview.qt-project.org/#/c/88596/ (about QAbstractState::active)
[4]
http://www.w3.org/TR/2014/WD-scxml-20140529/#AlgorithmforSCXMLInterpretation

-- 
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4833 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140702/7562ab08/attachment.bin>


More information about the Development mailing list