summaryrefslogtreecommitdiffstats
path: root/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-08-14 02:51:17 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-08-19 19:17:18 +0300
commitea24142ab5d8da7c47a7075696b5b8227ddf6458 (patch)
tree4c3831173af6d2371166f2381c9e5048f3d7754e /tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
parent78f025005357b594e8c9abd13419b6ae693b0272 (diff)
tst_QPrintDevice: compile with QT_NO_FOREACH
The loop was iterating over a temporary, so it couldn't have changed it. Store the container in a local const variable and port to ranged-for. Drive-by change: don't call ps->availablePrintDeviceIds() multiple times. Task-number: QTBUG-115839 Change-Id: If2cabec68040dc7096acf0b7ddeff72d7c8c7750 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp')
-rw-r--r--tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
index 2221f9d920..fefce34d99 100644
--- a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
+++ b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
@@ -1,8 +1,6 @@
// Copyright (C) 2014 John Layt <jlayt@kde.org>
// 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 <QTest>
#include <QMimeType>
@@ -27,16 +25,17 @@ void tst_QPrintDevice::basics()
QSKIP("Could not load platform plugin");
QString defaultId = ps->defaultPrintDeviceId();
+ const QStringList availableIds = ps->availablePrintDeviceIds();
if (defaultId.isEmpty()) {
qDebug() << "No default printer found";
} else {
- QVERIFY(ps->availablePrintDeviceIds().contains(defaultId));
+ QVERIFY(availableIds.contains(defaultId));
}
- qDebug() << "Available Printer IDs :" << ps->availablePrintDeviceIds();
+ qDebug() << "Available Printer IDs :" << availableIds;
// Just exercise the api for now as we don't know what is installed
- foreach (const QString id, ps->availablePrintDeviceIds()) {
+ for (const QString &id : availableIds) {
QPrintDevice printDevice = ps->createPrintDevice(id);
const char quote = id == defaultId ? '*' : '"';
qDebug().noquote().nospace() << "\nCreated printer " << quote << id