summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--.cmake.conf1
-rw-r--r--src/datavisualization/CMakeLists.txt14
-rw-r--r--src/datavisualization/engine/abstract3dcontroller.cpp2
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp2
-rw-r--r--src/datavisualization/engine/axisrendercache.cpp2
-rw-r--r--src/datavisualization/engine/bars3dcontroller.cpp2
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp2
-rw-r--r--src/datavisualization/engine/q3dscatter.cpp2
-rw-r--r--src/datavisualization/engine/q3dsurface.cpp2
-rw-r--r--src/datavisualization/engine/scatter3dcontroller.cpp2
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp2
-rw-r--r--src/datavisualization/engine/surface3dcontroller.cpp2
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp2
-rw-r--r--src/datavisualizationqml/CMakeLists.txt2
-rw-r--r--src/datavisualizationqml/abstractdeclarative.cpp2
-rw-r--r--src/datavisualizationqml/declarativetheme.cpp2
-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
23 files changed, 57 insertions, 2 deletions
diff --git a/.cmake.conf b/.cmake.conf
index e17d1c4c..734bc2d5 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -1,3 +1,4 @@
set(QT_REPO_MODULE_VERSION "6.7.0")
set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1")
+list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_FOREACH=1")
diff --git a/src/datavisualization/CMakeLists.txt b/src/datavisualization/CMakeLists.txt
index 6d327736..fb216466 100644
--- a/src/datavisualization/CMakeLists.txt
+++ b/src/datavisualization/CMakeLists.txt
@@ -82,6 +82,20 @@ qt_internal_add_module(DataVisualization
utils/vertexindexer.cpp utils/vertexindexer_p.h
DEFINES
QT_NO_CONTEXTLESS_CONNECT
+ NO_PCH_SOURCES
+ # undef QT_NO_FOREACH:
+ engine/abstract3dcontroller.cpp
+ engine/abstract3drenderer.cpp
+ engine/axisrendercache.cpp
+ engine/bars3dcontroller.cpp
+ engine/bars3drenderer.cpp
+ engine/q3dscatter.cpp
+ engine/q3dsurface.cpp
+ engine/scatter3dcontroller.cpp
+ engine/scatter3drenderer.cpp
+ engine/surface3dcontroller.cpp
+ engine/surface3drenderer.cpp
+ # end undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
axis
data
diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp
index da5fd645..f7d7f206 100644
--- a/src/datavisualization/engine/abstract3dcontroller.cpp
+++ b/src/datavisualization/engine/abstract3dcontroller.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 "abstractdeclarativeinterface_p.h"
#include "abstract3dcontroller_p.h"
#include "qabstract3daxis_p.h"
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 1fab2bdb..7bd451c4 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.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 "abstract3drenderer_p.h"
#include "texturehelper_p.h"
#include "q3dcamera_p.h"
diff --git a/src/datavisualization/engine/axisrendercache.cpp b/src/datavisualization/engine/axisrendercache.cpp
index 6fc80cd6..1218eec2 100644
--- a/src/datavisualization/engine/axisrendercache.cpp
+++ b/src/datavisualization/engine/axisrendercache.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 "axisrendercache_p.h"
#include <QtGui/QFontMetrics>
diff --git a/src/datavisualization/engine/bars3dcontroller.cpp b/src/datavisualization/engine/bars3dcontroller.cpp
index fd6aae65..a307f2f4 100644
--- a/src/datavisualization/engine/bars3dcontroller.cpp
+++ b/src/datavisualization/engine/bars3dcontroller.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 "bars3dcontroller_p.h"
#include "bars3drenderer_p.h"
#include "qvalue3daxis_p.h"
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 76b616cd..8d2d9cce 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.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 "bars3drenderer_p.h"
#include "q3dcamera_p.h"
#include "shaderhelper_p.h"
diff --git a/src/datavisualization/engine/q3dscatter.cpp b/src/datavisualization/engine/q3dscatter.cpp
index 4e5ac2d8..07c86110 100644
--- a/src/datavisualization/engine/q3dscatter.cpp
+++ b/src/datavisualization/engine/q3dscatter.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 "q3dscatter.h"
#include "q3dscatter_p.h"
diff --git a/src/datavisualization/engine/q3dsurface.cpp b/src/datavisualization/engine/q3dsurface.cpp
index 0c66c32f..2b456814 100644
--- a/src/datavisualization/engine/q3dsurface.cpp
+++ b/src/datavisualization/engine/q3dsurface.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 "q3dsurface.h"
#include "q3dsurface_p.h"
diff --git a/src/datavisualization/engine/scatter3dcontroller.cpp b/src/datavisualization/engine/scatter3dcontroller.cpp
index d26eac7c..af7bb204 100644
--- a/src/datavisualization/engine/scatter3dcontroller.cpp
+++ b/src/datavisualization/engine/scatter3dcontroller.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 "scatter3dcontroller_p.h"
#include "scatter3drenderer_p.h"
#include "qvalue3daxis_p.h"
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index 16bae194..6a224ebd 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.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 "scatter3drenderer_p.h"
#include "q3dcamera_p.h"
#include "shaderhelper_p.h"
diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp
index 03c870c1..13b32666 100644
--- a/src/datavisualization/engine/surface3dcontroller.cpp
+++ b/src/datavisualization/engine/surface3dcontroller.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 "surface3dcontroller_p.h"
#include "surface3drenderer_p.h"
#include "qvalue3daxis_p.h"
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 4faeea44..cffed56d 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.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 "surface3drenderer_p.h"
#include "q3dcamera_p.h"
#include "shaderhelper_p.h"
diff --git a/src/datavisualizationqml/CMakeLists.txt b/src/datavisualizationqml/CMakeLists.txt
index b4b16772..d0c0e21b 100644
--- a/src/datavisualizationqml/CMakeLists.txt
+++ b/src/datavisualizationqml/CMakeLists.txt
@@ -44,6 +44,8 @@ qt_internal_add_qml_module(DataVisualizationQml
enumtostringmap.cpp enumtostringmap_p.h
foreigntypes_p.h
glstatestore.cpp glstatestore_p.h
+ NO_PCH_SOURCES
+ declarativetheme.cpp # undef QT_NO_FOREACH
DEFINES
QT_NO_CONTEXTLESS_CONNECT
QML_FILES
diff --git a/src/datavisualizationqml/abstractdeclarative.cpp b/src/datavisualizationqml/abstractdeclarative.cpp
index 94dda0e6..b4e01003 100644
--- a/src/datavisualizationqml/abstractdeclarative.cpp
+++ b/src/datavisualizationqml/abstractdeclarative.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 "abstractdeclarative_p.h"
#include "declarativetheme_p.h"
#include "declarativerendernode_p.h"
diff --git a/src/datavisualizationqml/declarativetheme.cpp b/src/datavisualizationqml/declarativetheme.cpp
index 18dc4f8e..02f3becc 100644
--- a/src/datavisualizationqml/declarativetheme.cpp
+++ b/src/datavisualizationqml/declarativetheme.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 "declarativetheme_p.h"
QT_BEGIN_NAMESPACE
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>