From 8ce54407f27c209ad48d6ae3b15ad3230ffd0b93 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Fri, 11 Aug 2023 01:33:49 +0300 Subject: [PATCH] QGestureManager: port Q_FOREACH to ranged-for [6/6] These two QSetS are local to the function, the loop bodies don't modify them but they can't be made const due to the way they're filled. So use std::as_const and ranged-for. Un-blacklist the file, by removing "#undef QT_NO_FOREACH", and removing the source file from NO_PCH_SOURCES. Change-Id: I49b852aa865b0321d3e2f617466557d77143a32b Task-number: QTBUG-115803 Reviewed-by: Christian Ehrlicher Reviewed-by: Marc Mutz --- src/widgets/CMakeLists.txt | 1 - src/widgets/kernel/qgesturemanager.cpp | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 8117ed9a31..9e21cfafd5 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -70,7 +70,6 @@ qt_internal_add_module(Widgets "kernel/qt_widgets_pch.h" NO_PCH_SOURCES compat/removed_api.cpp - kernel/qgesturemanager.cpp # undef QT_NO_FOREACH GENERATE_CPP_EXPORTS ) diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index e2e6bcf328..c93876c500 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -1,8 +1,6 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses - #include "private/qgesturemanager_p.h" #include "private/qstandardgestures_p.h" #include "private/qwidget_p.h" @@ -332,9 +330,9 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMapd_func()->state = Qt::GestureStarted; - foreach (QGesture *gesture, triggeredGestures) + for (QGesture *gesture : std::as_const(triggeredGestures)) gesture->d_func()->state = Qt::GestureUpdated; - foreach (QGesture *gesture, finishedGestures) + for (QGesture *gesture : std::as_const(finishedGestures)) gesture->d_func()->state = Qt::GestureFinished; for (QGesture *gesture : canceledGestures) gesture->d_func()->state = Qt::GestureCanceled;