Commit 8fd8aba6 authored by Emmanuel Promayon's avatar Emmanuel Promayon

FIXED avoid using RTTI (qobject_cast does not use RTTI)

Catching all exception on windows, added a (strange) error: "Access violation - no RTTI data!"
This commit checks a solution that does not use RTTI and directly use the Q_OBJECT property.
parent 4c84409e
......@@ -47,6 +47,8 @@
*/
class ActionState : public QState {
Q_OBJECT
public:
/**
*/
......
......@@ -129,16 +129,18 @@ void ActionStateMachine::autoNext() {
setProperty("Message Box Level", InterfaceLogger::NONE);
// machine.configuration() returns all the current state, the first on is the active state
ActionState* currentState = dynamic_cast<ActionState*>(machine.configuration().toList().first());
ActionState* currentState = qobject_cast<ActionState*>(machine.configuration().toList().first());
// loop until no more state is available
while (currentState!=nullptr && currentState->transitions().size()>0) {
CAMITK_TRACE("current state = " + currentState->getName() + " (" + currentState->transitions().size() + " transitions)")
// look for the "Next" or "Quit" transition
QList<QAbstractTransition*>::iterator it = currentState->transitions().begin();
auto it = currentState->transitions().begin();
bool foundNextState = false;
while (it!=currentState->transitions().end() && !foundNextState) { // && nextState==nullptr) {
// all transition in this state machine are ActionTransition instances...
ActionTransition* currentActionTransition = dynamic_cast<ActionTransition*>(*it);
ActionTransition* currentActionTransition = qobject_cast<ActionTransition*>(*it);
CAMITK_TRACE("current transition = " + QString("0x%1").arg((quintptr)currentActionTransition, QT_POINTER_SIZE * 2, 16, QChar('0')))
//... in which we can look for the "Next" or "Quit" transition
if (currentActionTransition->isNamed("Next") || currentActionTransition->isNamed("Quit")) {
// activate the transition (simulate a click on the button)
......
......@@ -57,6 +57,7 @@ class ActionState;
*
*/
class ActionTransition : public QSignalTransition {
Q_OBJECT
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment