summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-05 23:48:44 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-08-18 10:22:24 +0200
commita84bf68892e93450e8c4ab1a6b90ae843dc6af35 (patch)
tree194359f727add776e48446e4db8b763df3aeebc1 /tests/manual
parent0c45ec75d82b480bc9a83095b297738b79c8980c (diff)
Mark the module as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses is high here, too high for this author, unfamiliar with this module, to tackle in a short amount of time. But they're concentrated in just a few TUs, so pick a different strategy: Mark the whole module with QT_NO_FOREACH, to prevent new uses from creeping in, and whitelist the affected TUs by #undef'ing QT_NO_FOREACH locally, at the top of each file. For TUs that are part of a larger executable, this requires these files to be compiled separately, so add them to NO_PCH_SOURCES (which implies NO_UNITY_BUILD_SOURCES, too). Created QTBUG-115807 to keep track of this. Ported one that was trivial and where whitelisting of the file with a single Q_FOREACH would have been more work than directly fixing it. Task-number: QTBUG-115807 Change-Id: I2fa6c740e35039baf34115af7d69d6c420e4de10 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/barstest/CMakeLists.txt2
-rw-r--r--tests/manual/barstest/chart.cpp2
-rw-r--r--tests/manual/itemmodeltest/main.cpp4
-rw-r--r--tests/manual/scattertest/CMakeLists.txt2
-rw-r--r--tests/manual/scattertest/scatterchart.cpp2
-rw-r--r--tests/manual/surfacetest/CMakeLists.txt2
-rw-r--r--tests/manual/surfacetest/graphmodifier.cpp2
7 files changed, 14 insertions, 2 deletions
diff --git a/tests/manual/barstest/CMakeLists.txt b/tests/manual/barstest/CMakeLists.txt
index 399ae44c..391b98aa 100644
--- a/tests/manual/barstest/CMakeLists.txt
+++ b/tests/manual/barstest/CMakeLists.txt
@@ -11,6 +11,8 @@ qt_internal_add_manual_test(barstest
buttonwrapper.cpp buttonwrapper.h
custominputhandler.cpp custominputhandler.h
main.cpp
+ NO_PCH_SOURCES
+ chart.cpp # undef QT_NO_FOREACH
)
target_link_libraries(barstest PUBLIC
Qt::Gui
diff --git a/tests/manual/barstest/chart.cpp b/tests/manual/barstest/chart.cpp
index 6a6291cc..d427921a 100644
--- a/tests/manual/barstest/chart.cpp
+++ b/tests/manual/barstest/chart.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 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 "chart.h"
#include "custominputhandler.h"
#include <QtDataVisualization/qcategory3daxis.h>
diff --git a/tests/manual/itemmodeltest/main.cpp b/tests/manual/itemmodeltest/main.cpp
index b2fadaea..32682ee3 100644
--- a/tests/manual/itemmodeltest/main.cpp
+++ b/tests/manual/itemmodeltest/main.cpp
@@ -208,8 +208,8 @@ void GraphDataGenerator::changeSelectedButtonClicked()
{
// Change all selected cells to a random value 1-10
QVariant value = QVariant::fromValue(QRandomGenerator::global()->bounded(10.0) + 1);
- QList<QTableWidgetItem *> selectedItems = m_tableWidget->selectedItems();
- foreach (QTableWidgetItem *item, selectedItems) {
+ const QList<QTableWidgetItem *> selectedItems = m_tableWidget->selectedItems();
+ for (QTableWidgetItem *item : selectedItems) {
QString oldData = item->data(Qt::DisplayRole).toString();
item->setData(Qt::DisplayRole,
oldData.left(5)
diff --git a/tests/manual/scattertest/CMakeLists.txt b/tests/manual/scattertest/CMakeLists.txt
index ac131567..89013c12 100644
--- a/tests/manual/scattertest/CMakeLists.txt
+++ b/tests/manual/scattertest/CMakeLists.txt
@@ -8,6 +8,8 @@ qt_internal_add_manual_test(scattertest
SOURCES
main.cpp
scatterchart.cpp scatterchart.h
+ NO_PCH_SOURCES
+ scatterchart.cpp # undef QT_NO_FOREACH
)
target_link_libraries(scattertest PUBLIC
Qt::Gui
diff --git a/tests/manual/scattertest/scatterchart.cpp b/tests/manual/scattertest/scatterchart.cpp
index 8a521a2e..fce115d4 100644
--- a/tests/manual/scattertest/scatterchart.cpp
+++ b/tests/manual/scattertest/scatterchart.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 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 "scatterchart.h"
#include <QtDataVisualization/qscatterdataproxy.h>
#include <QtDataVisualization/qscatter3dseries.h>
diff --git a/tests/manual/surfacetest/CMakeLists.txt b/tests/manual/surfacetest/CMakeLists.txt
index 42e8bf07..bb3f0500 100644
--- a/tests/manual/surfacetest/CMakeLists.txt
+++ b/tests/manual/surfacetest/CMakeLists.txt
@@ -10,6 +10,8 @@ qt_internal_add_manual_test(surfacetest
checkboxwrapper.cpp checkboxwrapper.h
graphmodifier.cpp graphmodifier.h
main.cpp
+ NO_PCH_SOURCES
+ graphmodifier.cpp # undef QT_NO_FOREACH
)
target_link_libraries(surfacetest PUBLIC
Qt::Gui
diff --git a/tests/manual/surfacetest/graphmodifier.cpp b/tests/manual/surfacetest/graphmodifier.cpp
index fb0e4e6d..f406513d 100644
--- a/tests/manual/surfacetest/graphmodifier.cpp
+++ b/tests/manual/surfacetest/graphmodifier.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 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 "graphmodifier.h"
#include <QtDataVisualization/QValue3DAxis>
#include <QtDataVisualization/QSurfaceDataProxy>