From e2e0dfee7c675c91132197b4a01a394a5da9a36f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 11 May 2016 11:53:02 +0200 Subject: QtCore/QtDBus/QtSql: port the last remaining Q_FOREACH loop and add QT_NO_FOREACH Port the last remaining Q_FOREACH user in QtCore to C++11 range-for and mark QtCore, QtSql and QtDBus as Q_FOREACH-free, using QT_NO_FOREACH. Change-Id: Ia6f99139cb1ca4a8bbe9e445421592242e048b0a Reviewed-by: Thiago Macieira --- src/corelib/statemachine/qstatemachine.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib/statemachine') diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index d5b01f3c8a..e3cfd7b988 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1778,7 +1778,11 @@ void QStateMachinePrivate::_q_start() { Q_Q(QStateMachine); Q_ASSERT(state == Starting); - foreach (QAbstractState *state, configuration) { + // iterate over a copy, since we emit signals which may cause + // 'configuration' to change, resulting in undefined behavior when + // iterating at the same time: + const auto config = configuration; + for (QAbstractState *state : config) { QAbstractStatePrivate *abstractStatePrivate = QAbstractStatePrivate::get(state); abstractStatePrivate->active = false; emit state->activeChanged(false); -- cgit v1.2.3