From 3f94513670fd6dc2a2ab68ec806df6eb1fa2c46c Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Wed, 11 Oct 2023 18:37:16 +0300 Subject: [PATCH] QGestureManager: port to ranged-for [2/6] The enclosing iterator-based loop: the loop body doesn't modify the `m_objectGestures` QMap (the original loop was using const_iterators), so port to ranged-for by using asKeyValueRange(). The foreach loop: the loop body doesn't modify the `gestures` QList, so a simple port to ranged-for. Task-number: QTBUG-115803 Change-Id: I92ba7ff6ef878d7e4b7115a8fab87e95a6d93182 Reviewed-by: Marc Mutz Reviewed-by: Christian Ehrlicher --- src/widgets/kernel/qgesturemanager.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 523d140d77..071b7ad4a0 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -106,11 +106,9 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) } } - QMap >::const_iterator iter = m_objectGestures.constBegin(); - while (iter != m_objectGestures.constEnd()) { - ObjectGesture objectGesture = iter.key(); + for (const auto &[objectGesture, gestures] : std::as_const(m_objectGestures).asKeyValueRange()) { if (objectGesture.gesture == type) { - foreach (QGesture *g, iter.value()) { + for (QGesture *g : gestures) { auto it = m_gestureToRecognizer.constFind(g); if (it != m_gestureToRecognizer.cend() && it.value()) { QGestureRecognizer *recognizer = it.value(); @@ -119,7 +117,6 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) } } } - ++iter; } }