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 <ch.ehrlicher@gmx.de>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Ahmad Samir 2023-08-11 01:33:49 +03:00
parent 2309b38a64
commit 8ce54407f2
2 changed files with 2 additions and 5 deletions

View File

@ -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
)

View File

@ -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 QMultiMap<QObject *,
// set the proper gesture state on each gesture
for (QGesture *gesture : startedGestures)
gesture->d_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;