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>
This commit is contained in:
parent
78f0250053
commit
ea24142ab5
@ -1,8 +1,6 @@
|
|||||||
// Copyright (C) 2014 John Layt <jlayt@kde.org>
|
// 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
|
// 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 <QTest>
|
||||||
#include <QMimeType>
|
#include <QMimeType>
|
||||||
|
|
||||||
@ -27,16 +25,17 @@ void tst_QPrintDevice::basics()
|
|||||||
QSKIP("Could not load platform plugin");
|
QSKIP("Could not load platform plugin");
|
||||||
|
|
||||||
QString defaultId = ps->defaultPrintDeviceId();
|
QString defaultId = ps->defaultPrintDeviceId();
|
||||||
|
const QStringList availableIds = ps->availablePrintDeviceIds();
|
||||||
if (defaultId.isEmpty()) {
|
if (defaultId.isEmpty()) {
|
||||||
qDebug() << "No default printer found";
|
qDebug() << "No default printer found";
|
||||||
} else {
|
} 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
|
// 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);
|
QPrintDevice printDevice = ps->createPrintDevice(id);
|
||||||
const char quote = id == defaultId ? '*' : '"';
|
const char quote = id == defaultId ? '*' : '"';
|
||||||
qDebug().noquote().nospace() << "\nCreated printer " << quote << id
|
qDebug().noquote().nospace() << "\nCreated printer " << quote << id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user