Reviewing merge request #1: Small bug fix !
Hello ,
I've got a crash with source produced by scc.
this is a small example to explain my problem :
//#######################cut here
//controller.scxml
<?xml version="1.0" encoding="ISO-8859-1"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:Qt="http://www.qtsoftware.com scxml-ext"
initial="test">
<state id="test">
<transition event="test(bool)" cond="_event.data[0].toBool()" target="test" />
</state>
</scxml>
//#######################cut here
//main.cpp :
#include <QApplication>
#include "sc_controller.h"
class Test : public SMClass_controller
{
Q_OBJECT
public:
Test(QObject* o = NULL):SMClass_controller(o) {
setupStateMachine();
start();
QTimer::singleShot(5000,this,SLOT(test()));
}
public slots:
void test() {
event_test(true);
}
};
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
Test t;
return a.exec();
}
#include <main.moc>
//#######################cut here
This example produce a crash when trying to execute : cond="_event.data[0].toBool()"
$ gdb -q ./test_scxml
Reading symbols for shared libraries ..... done
(gdb) r
Starting program: /Users/hsivank/Desktop/test_scxml/test_scxml
Reading symbols for shared libraries .++++.............................................................................................. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
ASSERT failure in QList<T>::operator[]: "index out of range", file /opt/local/libexec/qt4-mac/include/QtCore/qlist.h, line 447
Program received signal SIGABRT, Aborted.
0x00007fff87286fe6 in __kill ()
(gdb) bt
#0 0x00007fff87286fe6 in __kill ()
#1 0x00007fff87327e32 in abort ()
#2 0x0000000100b1cdef in qt_message_output ()
#3 0x0000000100b1cf88 in qt_message ()
#4 0x0000000100b1d159 in qFatal ()
#5 0x0000000100b6764e in qt_assert_x ()
#6 0x000000010000458e in QList<QVariant>::operator[] (this=0x7fff5fbff7b8, i=0) at qlist.h:447
#7 0x000000010000460c in SMClass_controller::testCondition_T430966940870 (this=0x7fff5fbff798) at sc_controller.h:67
#8 0x000000010000339c in (anonymous namespace)::Transition_T430966940870::eventTest (this=0x100fab410, e=0x10211ad60) at sc_controller.h:116
#9 0x0000000100c1fabe in QAbstractTransitionPrivate::callEventTest ()
#10 0x0000000100c17122 in QStateMachinePrivate::selectTransitions ()
#11 0x0000000100c172fa in QStateMachinePrivate::_q_process ()
#12 0x0000000100c17833 in QStateMachinePrivate::processEvents ()
#13 0x0000000100c18f6c in QStateMachinePrivate::handleTransitionSignal ()
#14 0x0000000100c138a5 in QSignalEventGenerator::qt_metacall ()
#15 0x0000000100b51138 in QMetaObject::metacall ()
#16 0x0000000100b53707 in QMetaObject::activate ()
#17 0x0000000100004906 in SMClass_controller::event_test (this=0x7fff5fbff798, _t1=true) at moc_sc_controller.cpp:89
#18 0x0000000100003b62 in Test::test (this=0x7fff5fbff798) at main.cpp:21
#19 0x0000000100003153 in Test::qt_metacall (this=0x7fff5fbff798, _c=InvokeMetaMethod, _id=0, _a=0x7fff5fbfde30) at main.moc:71
#20 0x0000000100b51138 in QMetaObject::metacall ()
#21 0x0000000100b53707 in QMetaObject::activate ()
#22 0x0000000100c01365 in QSingleShotTimer::timerEvent ()
#23 0x0000000100bfdbf1 in QObject::event ()
#24 0x000000010007592a in QApplicationPrivate::notify_helper ()
#25 0x0000000100076d22 in QApplication::notify ()
#26 0x0000000100b502e8 in QCoreApplication::notifyInternal ()
#27 0x0000000100074e78 in qt_sendSpontaneousEvent ()
#28 0x0000000100038c63 in QEventDispatcherMacPrivate::activateTimer ()
#29 0x00007fff8869da58 in __CFRunLoopRun ()
#30 0x00007fff8869bc2f in CFRunLoopRunSpecific ()
#31 0x00007fff8422ea4e in RunCurrentEventLoopInMode ()
#32 0x00007fff8422e853 in ReceiveNextEventCommon ()
#33 0x00007fff8422e70c in BlockUntilNextEventMatchingListInMode ()
#34 0x00007fff835ef1f2 in _DPSNextEvent ()
#35 0x00007fff835eeb41 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#36 0x00007fff835b4747 in -[NSApplication run] ()
#37 0x0000000100039cd2 in QEventDispatcherMac::processEvents ()
#38 0x0000000100bf005a in QEventLoop::processEvents ()
#39 0x0000000100bf01be in QEventLoop::exec ()
#40 0x0000000100bf15a8 in QCoreApplication::exec ()
#41 0x0000000100077418 in QApplication::exec ()
#42 0x0000000100002d7c in main (argc=1, argv=0x7fff5fbff868) at main.cpp:31
(gdb)
=> _event.data is empty ...
looking at scc/scc.xslt:271, it seems that beginSelectTransitions(QEvent *event) is added *IF* Qt:property is present in scxml file
I would like to know if there is any reason to not always add beginSelectTransitions(QEvent *event) ?
Thanks a lot in advance.
PS : scxml is realy a cool feature for Qt :-)
Commits that would be merged:
Comments
Hi hsivank
Sorry for not getting back to you earlier.
The reason for the test is because all we do in beginSelectTransitions is calling assignProperties(), and there’s not really a a point in doing that when there aren’t any properties…
I'm having a hard time seeing how the proposed fix is related to the crash, or are these two separate issues?
Cheers
No'am
Hello No'am,
“The reason for the test is because all we do in beginSelectTransitions is calling assignProperties(), and there’s not really a point in doing that when there aren’t any properties…”
It is not really true :
If there are properties beginSelectTransitions looks like :
virtual void beginSelectTransitions(QEvent *event)
{
if (event && !event->type() == QEvent::None) {
switch (event->type()) {
case QEvent::StateMachineSignal: {
QStateMachine::SignalEvent* e = (QStateMachine::SignalEvent*)event;
_event.data = e->arguments();
_event.name = e->sender()->metaObject()->method(e->signalIndex()).signature();
if (e->sender() == this)
_event.name = _event.name.mid(6);
} break;
default:
break;
}
} else {
_event.name = "";
_event.data.clear();
}
assignProperties();
}
Each time an event occurs, arguments are stored into _event.data …
In my example beginSelectTransitions doesn’t exist (cause there are no properties) … So _event.data is always empty( it explains the crash, i cannot access argument pass to signal)
Maybe beginSelectTransitions should always be integrated into file produced by scc but assignProperties() call should be optional ?
You’re absolutely right, I was looking at an older version.
Merging your change, though it takes a bit for it to mirror to our public gitorious
Thanks
No'am


Add a new comment:
Login or create an account to post a comment