summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qtemporarydir
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-08-11 03:09:40 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-08-19 16:29:09 +0300
commite7b07b64c7b0536eccba6ff25e23badb88226813 (patch)
treed70ab6c7451f2e6b62887684fe3ab528d345a577 /tests/auto/corelib/io/qtemporarydir
parentc7a8e1e9928fc2b84e6179adc69c858b17b25d48 (diff)
tests/auto/*: port Q_FOREACH to ranged-for
The loop was iterating over a temporary container, so it couldn't have changed it. Store the container in a const auto variable and use ranged-for. In files where Q_FOREACH isn't used any more, remove "#undef QT_NO_FOREACH". Task-number: QTBUG-115839 Change-Id: I402df5fa48f4287f3cc989ddae1524da43999049 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/corelib/io/qtemporarydir')
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index bd371f1e0f..2db1f1f98b 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -391,7 +391,8 @@ void tst_QTemporaryDir::openOnRootDrives()
#endif
// If it's possible to create a file in the root directory, it
// must be possible to create a temp dir there too.
- foreach (const QFileInfo &driveInfo, QDir::drives()) {
+ const auto drives = QDir::drives();
+ for (const QFileInfo &driveInfo : drives) {
QFile testFile(driveInfo.filePath() + "XXXXXX");
if (testFile.open(QIODevice::ReadWrite)) {
testFile.remove();