From 0069f50019462a3dd95d1610361d00d91bf4afe1 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 29 Sep 2009 16:28:29 -0700 Subject: Rebuild configure.exe Bring it up-to-date with commit 950f80620b56e9ed277240dc16087f3e4b53cc4a. --- configure.exe | Bin 1167872 -> 1168896 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 12e8431..aa254f3 100755 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 86a30b667e189b8659fab384d93022e55a67b81e Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 29 Sep 2009 16:41:48 +0200 Subject: Remove "inline" keyword from unused constructors Found during API review, make the private safety constructors follow the pattern of our Q_DISABLE_COPY macro. Reviewed-by: Robert Griebl --- src/script/api/qscriptvalue.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/script/api/qscriptvalue.h b/src/script/api/qscriptvalue.h index 2bc89bd..32f7a43 100644 --- a/src/script/api/qscriptvalue.h +++ b/src/script/api/qscriptvalue.h @@ -216,9 +216,9 @@ public: private: // force compile error, prevent QScriptValue(bool) to be called - inline QScriptValue(void *); + QScriptValue(void *); // force compile error, prevent QScriptValue(QScriptEngine*, bool) to be called - inline QScriptValue(QScriptEngine *, void *); + QScriptValue(QScriptEngine *, void *); QScriptValue(QScriptValuePrivate*); -- cgit v0.12 From 544f06f1fe29e986cd2b3fd1fd7198d688275969 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 29 Sep 2009 16:40:48 +0200 Subject: Make sure delayed events are cancelled when a state machine halts Otherwise the events might creep into the event loop if the state machine is restarted. Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/statemachine/qstatemachine.cpp | 20 +++++++++++++ src/corelib/statemachine/qstatemachine_p.h | 1 + tests/auto/qstatemachine/tst_qstatemachine.cpp | 39 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 256763b..c7144e4 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1265,11 +1265,13 @@ void QStateMachinePrivate::_q_process() break; case Finished: state = NotRunning; + cancelAllDelayedEvents(); unregisterAllTransitions(); emit q->finished(); break; case Stopped: state = NotRunning; + cancelAllDelayedEvents(); unregisterAllTransitions(); emit q->stopped(); break; @@ -1291,6 +1293,19 @@ void QStateMachinePrivate::processEvents(EventProcessingMode processingMode) } } +void QStateMachinePrivate::cancelAllDelayedEvents() +{ + Q_Q(QStateMachine); + QHash::const_iterator it; + for (it = delayedEvents.constBegin(); it != delayedEvents.constEnd(); ++it) { + int id = it.key(); + QEvent *e = it.value(); + q->killTimer(id); + delete e; + } + delayedEvents.clear(); +} + namespace { class GoToStateTransition : public QAbstractTransition @@ -1946,6 +1961,11 @@ bool QStateMachine::event(QEvent *e) if (e->type() == QEvent::Timer) { QTimerEvent *te = static_cast(e); int tid = te->timerId(); + if (d->state != QStateMachinePrivate::Running) { + // This event has been cancelled already + Q_ASSERT(!d->delayedEvents.contains(tid)); + return true; + } QEvent *ee = d->delayedEvents.take(tid); if (ee != 0) { killTimer(tid); diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 141bc5c..cf7a073 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -160,6 +160,7 @@ public: void handleTransitionSignal(QObject *sender, int signalIndex, void **args); void processEvents(EventProcessingMode processingMode); + void cancelAllDelayedEvents(); #ifndef QT_NO_PROPERTIES typedef QPair RestorableId; diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 463dbf6..b808f7f 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -120,6 +120,7 @@ private slots: void assignPropertyWithAnimation(); void postEvent(); void cancelDelayedEvent(); + void postDelayedEventAndStop(); void stateFinished(); void parallelStates(); void parallelRootState(); @@ -1638,6 +1639,44 @@ void tst_QStateMachine::cancelDelayedEvent() QVERIFY(machine.configuration().contains(s2)); } +void tst_QStateMachine::postDelayedEventAndStop() +{ + QStateMachine machine; + QState *s1 = new QState(&machine); + QFinalState *s2 = new QFinalState(&machine); + s1->addTransition(new StringTransition("a", s2)); + machine.setInitialState(s1); + + QSignalSpy startedSpy(&machine, SIGNAL(started())); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 1); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + int id1 = machine.postDelayedEvent(new StringEvent("a"), 0); + QVERIFY(id1 != -1); + QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); + machine.stop(); + QTRY_COMPARE(stoppedSpy.count(), 1); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + machine.start(); + QTRY_COMPARE(startedSpy.count(), 2); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + int id2 = machine.postDelayedEvent(new StringEvent("a"), 1000); + QVERIFY(id2 != -1); + machine.stop(); + QTRY_COMPARE(stoppedSpy.count(), 2); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 3); + QTestEventLoop::instance().enterLoop(2); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); +} + void tst_QStateMachine::stateFinished() { QStateMachine machine; -- cgit v0.12