summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFrans Englich <frans.englich@nokia.com>2009-09-29 14:48:54 (GMT)
committerFrans Englich <frans.englich@nokia.com>2009-09-29 14:48:54 (GMT)
commitc275874bf96dbca05e9a2c15cd970138d78ac595 (patch)
tree89509226eb74ad860e8a3061893891f1d133fbf0 /src/corelib
parentb1c2caf933942b3a77a0332aecb66a7f0fdd2316 (diff)
parent544f06f1fe29e986cd2b3fd1fd7198d688275969 (diff)
downloadQt-c275874bf96dbca05e9a2c15cd970138d78ac595.zip
Qt-c275874bf96dbca05e9a2c15cd970138d78ac595.tar.gz
Qt-c275874bf96dbca05e9a2c15cd970138d78ac595.tar.bz2
Merge commit 'qt/4.6' into mmfphonon
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp20
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h1
2 files changed, 21 insertions, 0 deletions
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<int, QEvent*>::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<QTimerEvent*>(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<QObject *, QByteArray> RestorableId;