diff options
author | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-05-12 13:06:46 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-05-19 08:03:46 +0000 |
commit | 67d255f18343d74bbc9a0eec460995ca615473be (patch) | |
tree | a935d1dd031845cfaecea5e421ab9a3ff605bcaa /src/corelib/statemachine | |
parent | 009b11c30086f2ab40d3e86691f34cad31999a8f (diff) |
QStateMachine: empty the whole internal queue before external queue
If the internal queue contained multiple events, but the first one did
not select any transitions, the external event queue would be checked
before the remaining events in the internal queue.
Change-Id: I1a7f49afdefaaf2b4330bf13b079b61344385ea0
Task-number: QTBUG-46059
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index bea6822ecc..e5d019dc8b 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1925,7 +1925,7 @@ void QStateMachinePrivate::_q_process() delete e; e = 0; } - if (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) { + while (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) { #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": dequeued internal event" << e << "of type" << e->type(); #endif @@ -1935,8 +1935,7 @@ void QStateMachinePrivate::_q_process() e = 0; } } - if (enabledTransitions.isEmpty()) { - if ((e = dequeueExternalEvent()) != 0) { + while (enabledTransitions.isEmpty() && ((e = dequeueExternalEvent()) != 0)) { #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": dequeued external event" << e << "of type" << e->type(); #endif @@ -1945,24 +1944,19 @@ void QStateMachinePrivate::_q_process() delete e; e = 0; } - } else { - if (isInternalEventQueueEmpty()) { - processing = false; - stopProcessingReason = EventQueueEmpty; - } - } } - if (!enabledTransitions.isEmpty()) { - didChange = true; - q->beginMicrostep(e); - microstep(e, enabledTransitions, &calculationCache); - q->endMicrostep(e); - } - else { + if (enabledTransitions.isEmpty()) { + processing = false; + stopProcessingReason = EventQueueEmpty; noMicrostep(); #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": no transitions enabled"; #endif + } else { + didChange = true; + q->beginMicrostep(e); + microstep(e, enabledTransitions, &calculationCache); + q->endMicrostep(e); } delete e; } |