From 31a2cbbbc2dcf7d87a4b90c90c193e09e9676d6c Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Fri, 12 Aug 2016 14:19:33 +0300 Subject: Plugins: replace 'foreach' with 'range for' Mark some local variables as const to prevent detach()'ing. Use qAsConst where is not possible mark as const. If a container is changed in a loop's body, just make copy like 'foreach'. Change-Id: Ic453a688a9edf8a864d47f6e3a605164508a027c Reviewed-by: Ulf Hermann --- .../qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp') diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp index 3145601612..9eeb285951 100644 --- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp +++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp @@ -205,7 +205,7 @@ QQmlNativeDebugConnector::QQmlNativeDebugConnector() QQmlNativeDebugConnector::~QQmlNativeDebugConnector() { - foreach (QQmlDebugService *service, m_services) { + for (QQmlDebugService *service : qAsConst(m_services)) { service->stateAboutToBeChanged(QQmlDebugService::NotConnected); service->setState(QQmlDebugService::NotConnected); service->stateChanged(QQmlDebugService::NotConnected); @@ -232,12 +232,12 @@ void QQmlNativeDebugConnector::addEngine(QJSEngine *engine) Q_ASSERT(!m_engines.contains(engine)); TRACE_PROTOCOL("Add engine to connector:" << engine); - foreach (QQmlDebugService *service, m_services) + for (QQmlDebugService *service : qAsConst(m_services)) service->engineAboutToBeAdded(engine); announceObjectAvailability(QLatin1String("qmlengine"), engine, true); - foreach (QQmlDebugService *service, m_services) + for (QQmlDebugService *service : qAsConst(m_services)) service->engineAdded(engine); m_engines.append(engine); @@ -248,12 +248,12 @@ void QQmlNativeDebugConnector::removeEngine(QJSEngine *engine) Q_ASSERT(m_engines.contains(engine)); TRACE_PROTOCOL("Remove engine from connector:" << engine); - foreach (QQmlDebugService *service, m_services) + for (QQmlDebugService *service : qAsConst(m_services)) service->engineAboutToBeRemoved(engine); announceObjectAvailability(QLatin1String("qmlengine"), engine, false); - foreach (QQmlDebugService *service, m_services) + for (QQmlDebugService *service : qAsConst(m_services)) service->engineRemoved(engine); m_engines.removeOne(engine); -- cgit v1.2.3