tst_QKeyEvent: compile with QT_NO_FOREACH
The containers are local (window.keyEvents is a member of Window, which is constructed on the stack, so a local container too), and they are not changed during iteration, so use ranged-for and std::as_const. Drive-by change: make loop variable a const&. Task-number: QTBUG-115839 Change-Id: I9ad40068ff6209cf57f31ce0d4f38882eddbfc44 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
9b44acfd26
commit
6b7c354f5a
@ -1,8 +1,6 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
@ -69,7 +67,7 @@ void tst_QKeyEvent::basicEventDelivery()
|
||||
QCOMPARE(window.keyEvents.size(), 2);
|
||||
QCOMPARE(window.keyEvents.first()->type(), QKeyEvent::KeyPress);
|
||||
QCOMPARE(window.keyEvents.last()->type(), QKeyEvent::KeyRelease);
|
||||
foreach (const QKeyEvent *event, window.keyEvents) {
|
||||
for (const QKeyEvent *event : std::as_const(window.keyEvents)) {
|
||||
QCOMPARE(Qt::Key(event->key()), key);
|
||||
QCOMPARE(Qt::KeyboardModifiers(event->modifiers()), modifiers);
|
||||
}
|
||||
@ -139,7 +137,7 @@ void tst_QKeyEvent::modifiers_data()
|
||||
std::sort(modifierCombinations.begin(), modifierCombinations.end(), orderByModifier);
|
||||
|
||||
QTest::addColumn<Qt::KeyboardModifiers>("modifiers");
|
||||
foreach (const QList<int> combination, modifierCombinations) {
|
||||
for (const QList<int> &combination : std::as_const(modifierCombinations)) {
|
||||
int keys[4] = {};
|
||||
Qt::KeyboardModifiers mods;
|
||||
for (int i = 0; i < combination.size(); ++i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user