summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstatemachine
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-27 16:53:15 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-28 09:29:11 (GMT)
commite88a947cd8ac7bd78922a5468cd8b631b8ccf479 (patch)
tree72828b88f6f2b6707c61e7f131fca6ad54ed84bb /tests/auto/qstatemachine
parent399d7f19ea356a29933b5a08d66b791061586c87 (diff)
downloadQt-e88a947cd8ac7bd78922a5468cd8b631b8ccf479.zip
Qt-e88a947cd8ac7bd78922a5468cd8b631b8ccf479.tar.gz
Qt-e88a947cd8ac7bd78922a5468cd8b631b8ccf479.tar.bz2
Q_ASSERT failure in QStateMachinePrivate::handleTransitionSignal.
The signal index actually emitted was different from the signal index registered. This was due to recent changes in the meta-object protocol, where new indexes are being created (cloned) for signals with default parameters. When registering the transition signal, we now look for the original (non cloned) signal index. The transition keeps track of the user-specified signal index, and sets it when calling onTransition. Reviewed-by: Kent Hansen Reviewed-by: Olivier Goffart Task-number: 260403
Diffstat (limited to 'tests/auto/qstatemachine')
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 20e69ce..643daa2 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -93,10 +93,13 @@ Q_OBJECT
{ emit signalWithIntArg(arg); }
void emitSignalWithStringArg(const QString &arg)
{ emit signalWithStringArg(arg); }
+ void emitSignalWithDefaultArg()
+ { emit signalWithDefaultArg(); }
Q_SIGNALS:
void signalWithNoArg();
void signalWithIntArg(int);
void signalWithStringArg(const QString &);
+ void signalWithDefaultArg(int i = 42);
};
class tst_QStateMachine : public QObject
@@ -193,6 +196,8 @@ private slots:
void nestedStateMachines();
void goToState();
+
+ void task260403_clonedSignals();
};
tst_QStateMachine::tst_QStateMachine()
@@ -3937,5 +3942,42 @@ void tst_QStateMachine::goToState()
QVERIFY(machine.configuration().contains(s2_1));
}
+class CloneSignalTransition : public QSignalTransition
+{
+public:
+ CloneSignalTransition(QObject *sender, const char *signal, QAbstractState *target)
+ : QSignalTransition(sender, signal)
+ {
+ setTargetState(target);
+ }
+
+ void onTransition(QEvent *e)
+ {
+ QSignalTransition::onTransition(e);
+ QSignalEvent *se = static_cast<QSignalEvent*>(e);
+ eventSignalIndex = se->signalIndex();
+ }
+
+ int eventSignalIndex;
+};
+
+void tst_QStateMachine::task260403_clonedSignals()
+{
+ SignalEmitter emitter;
+ QStateMachine machine;
+ QState *s1 = new QState(&machine);
+ QState *s2 = new QState(&machine);
+ CloneSignalTransition *t1 = new CloneSignalTransition(&emitter, SIGNAL(signalWithDefaultArg()), s2);
+ s1->addTransition(t1);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QTest::qWait(1);
+
+ emitter.emitSignalWithDefaultArg();
+ QTest::qWait(1);
+ QCOMPARE(t1->eventSignalIndex, emitter.metaObject()->indexOfSignal("signalWithDefaultArg()"));
+}
+
QTEST_MAIN(tst_QStateMachine)
#include "tst_qstatemachine.moc"