tst_QAbstractFileEngine: compile with QT_NO_FOREACH
cleanupTestCase(): the loop doesn't modify the member container, so use std::as_const and a ranged-for. mounting(): the loop was iterating over a temporary QList, store it in a local auto variable and use ranged-for. Drive-by change: add braces to a multi-lined for block. Task-number: QTBUG-115839 Change-Id: I0542cad4df3730d6a09b39e64a54a84fc0d57062 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
0766d55d22
commit
645dcc27d3
@ -1,8 +1,6 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
|
||||
|
||||
#include <QtCore/private/qabstractfileengine_p.h>
|
||||
#include <QtCore/private/qfsfileengine_p.h>
|
||||
|
||||
@ -514,12 +512,13 @@ void tst_QAbstractFileEngine::cleanupTestCase()
|
||||
bool failed = false;
|
||||
|
||||
FileEngineHandler handler;
|
||||
Q_FOREACH(QString file, filesForRemoval)
|
||||
for (const QString &file : std::as_const(filesForRemoval)) {
|
||||
if (!QFile::remove(file)
|
||||
|| QFile::exists(file)) {
|
||||
failed = true;
|
||||
qDebug() << "Couldn't remove file:" << file;
|
||||
}
|
||||
}
|
||||
|
||||
QVERIFY(!failed);
|
||||
|
||||
@ -825,7 +824,8 @@ void tst_QAbstractFileEngine::mounting()
|
||||
QCOMPARE(dir.entryList(), (QStringList() << "bar" << "foo"));
|
||||
QDir dir2(fs.path());
|
||||
bool found = false;
|
||||
foreach (QFileInfo info, dir2.entryInfoList()) {
|
||||
const auto entries = dir2.entryInfoList();
|
||||
for (const QFileInfo &info : entries) {
|
||||
if (info.fileName() == QLatin1String("test.tar")) {
|
||||
QVERIFY(!found);
|
||||
found = true;
|
||||
|
Loading…
Reference in New Issue
Block a user