summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-07 10:14:49 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-08-18 12:30:41 +0200
commit6b1a4afc75c312ece7985177abf32637eeb2aaa7 (patch)
tree207ba617cc3fc88120a34a1ad10f21b247cbaa4c
parenta15f7570c67aabbab9beaa1e8eeb9631edebea58 (diff)
Mark QtCharts (the library) as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses is exremely high here, too high for this author, unfamiliar with this code, to tackle in a short amount of time. Even if they're not concentrated in just a few TUs, we need to make progress on a global QT_NO_FOREACH default, so grab the nettle and stick to our strategy: Mark the whole library 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-115824 to keep track of this, and other such follow-up changes in this module. Task-number: QTBUG-115824 Change-Id: If90d9e29bc4fdce1da97f663be35aa715bd6478b Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/charts/CMakeLists.txt46
-rw-r--r--src/charts/animations/boxplotanimation.cpp2
-rw-r--r--src/charts/animations/candlestickanimation.cpp2
-rw-r--r--src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.cpp2
-rw-r--r--src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.cpp2
-rw-r--r--src/charts/axis/barcategoryaxis/qbarcategoryaxis.cpp2
-rw-r--r--src/charts/axis/cartesianchartaxis.cpp2
-rw-r--r--src/charts/axis/categoryaxis/chartcategoryaxisx.cpp2
-rw-r--r--src/charts/axis/categoryaxis/chartcategoryaxisy.cpp2
-rw-r--r--src/charts/axis/chartaxiselement.cpp2
-rw-r--r--src/charts/axis/datetimeaxis/chartdatetimeaxisx.cpp2
-rw-r--r--src/charts/axis/datetimeaxis/chartdatetimeaxisy.cpp2
-rw-r--r--src/charts/axis/logvalueaxis/chartlogvalueaxisx.cpp2
-rw-r--r--src/charts/axis/logvalueaxis/chartlogvalueaxisy.cpp2
-rw-r--r--src/charts/axis/polarchartaxis.cpp2
-rw-r--r--src/charts/axis/polarchartaxisangular.cpp2
-rw-r--r--src/charts/axis/polarchartaxisradial.cpp2
-rw-r--r--src/charts/axis/valueaxis/chartvalueaxisx.cpp2
-rw-r--r--src/charts/axis/valueaxis/chartvalueaxisy.cpp2
-rw-r--r--src/charts/barchart/abstractbarchartitem.cpp2
-rw-r--r--src/charts/barchart/qabstractbarseries.cpp2
-rw-r--r--src/charts/boxplotchart/boxplotchartitem.cpp2
-rw-r--r--src/charts/boxplotchart/qboxplotseries.cpp2
-rw-r--r--src/charts/candlestickchart/candlestickchartitem.cpp2
-rw-r--r--src/charts/candlestickchart/qcandlestickseries.cpp2
-rw-r--r--src/charts/chartdataset.cpp2
-rw-r--r--src/charts/chartpresenter.cpp3
-rw-r--r--src/charts/chartthememanager.cpp3
-rw-r--r--src/charts/glwidget.cpp2
-rw-r--r--src/charts/layout/polarchartlayout.cpp2
-rw-r--r--src/charts/legend/legendlayout.cpp2
-rw-r--r--src/charts/legend/qlegend.cpp2
-rw-r--r--src/charts/piechart/piechartitem.cpp2
-rw-r--r--src/charts/piechart/qpieseries.cpp2
-rw-r--r--src/charts/qchart.cpp2
-rw-r--r--src/charts/xychart/glxyseriesdata.cpp2
-rw-r--r--src/charts/xychart/qxyseries.cpp2
37 files changed, 120 insertions, 0 deletions
diff --git a/src/charts/CMakeLists.txt b/src/charts/CMakeLists.txt
index a9131780..fa0c92cb 100644
--- a/src/charts/CMakeLists.txt
+++ b/src/charts/CMakeLists.txt
@@ -97,6 +97,32 @@ qt_internal_add_module(Charts
xychart/qxymodelmapper.cpp xychart/qxymodelmapper.h xychart/qxymodelmapper_p.h
xychart/qxyseries.cpp xychart/qxyseries.h xychart/qxyseries_p.h
xychart/xychart.cpp xychart/xychart_p.h
+ NO_PCH_SOURCES
+ # these all contain Q_FOREACH, so need to undef QT_NO_FOREACH
+ axis/barcategoryaxis/chartbarcategoryaxisx.cpp
+ axis/barcategoryaxis/chartbarcategoryaxisy.cpp
+ axis/barcategoryaxis/qbarcategoryaxis.cpp
+ axis/cartesianchartaxis.cpp
+ axis/categoryaxis/chartcategoryaxisx.cpp
+ axis/categoryaxis/chartcategoryaxisy.cpp
+ axis/chartaxiselement.cpp
+ axis/logvalueaxis/chartlogvalueaxisx.cpp
+ axis/logvalueaxis/chartlogvalueaxisy.cpp
+ axis/polarchartaxis.cpp
+ axis/polarchartaxisangular.cpp
+ axis/polarchartaxisradial.cpp
+ axis/valueaxis/chartvalueaxisx.cpp
+ axis/valueaxis/chartvalueaxisy.cpp
+ chartdataset.cpp
+ chartpresenter.cpp
+ chartthememanager.cpp
+ layout/polarchartlayout.cpp
+ legend/legendlayout.cpp
+ legend/qlegend.cpp
+ qchart.cpp
+ xychart/glxyseriesdata.cpp
+ xychart/qxyseries.cpp
+ # end undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
animations
axis
@@ -120,11 +146,14 @@ qt_internal_add_module(Charts
GENERATE_PRIVATE_CPP_EXPORTS
DEFINES
QT_NO_CONTEXTLESS_CONNECT
+ QT_NO_FOREACH
)
qt_internal_extend_target(Charts CONDITION QT_FEATURE_opengl
SOURCES
glwidget.cpp glwidget_p.h
+ NO_PCH_SOURCES
+ glwidget.cpp # undef QT_NO_FOREACH
PUBLIC_LIBRARIES
Qt::OpenGL
Qt::OpenGLWidgets
@@ -162,6 +191,9 @@ qt_internal_extend_target(Charts CONDITION QT_FEATURE_charts_bar_chart
barchart/vertical/stacked/qstackedbarseries.cpp barchart/vertical/stacked/qstackedbarseries.h barchart/vertical/stacked/qstackedbarseries_p.h
barchart/vertical/stacked/stackedbarchartitem.cpp barchart/vertical/stacked/stackedbarchartitem_p.h
legend/qbarlegendmarker.cpp legend/qbarlegendmarker.h legend/qbarlegendmarker_p.h
+ NO_PCH_SOURCES
+ barchart/abstractbarchartitem.cpp # undef QT_NO_FOREACH
+ barchart/qabstractbarseries.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
barchart
barchart/horizontal/bar
@@ -193,6 +225,9 @@ qt_internal_extend_target(Charts CONDITION QT_FEATURE_charts_pie_chart
piechart/qpieseries.cpp piechart/qpieseries.h piechart/qpieseries_p.h
piechart/qpieslice.cpp piechart/qpieslice.h piechart/qpieslice_p.h
piechart/qvpiemodelmapper.cpp piechart/qvpiemodelmapper.h
+ NO_PCH_SOURCES
+ piechart/piechartitem.cpp # undef QT_NO_FOREACH
+ piechart/qpieseries.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
piechart
)
@@ -228,6 +263,10 @@ qt_internal_extend_target(Charts CONDITION QT_FEATURE_charts_boxplot_chart
boxplotchart/qhboxplotmodelmapper.cpp boxplotchart/qhboxplotmodelmapper.h
boxplotchart/qvboxplotmodelmapper.cpp boxplotchart/qvboxplotmodelmapper.h
legend/qboxplotlegendmarker.cpp legend/qboxplotlegendmarker.h legend/qboxplotlegendmarker_p.h
+ NO_PCH_SOURCES
+ animations/boxplotanimation.cpp # undef QT_NO_FOREACH
+ boxplotchart/boxplotchartitem.cpp # undef QT_NO_FOREACH
+ boxplotchart/qboxplotseries.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
boxplotchart
)
@@ -245,6 +284,10 @@ qt_internal_extend_target(Charts CONDITION QT_FEATURE_charts_candlestick_chart
candlestickchart/qhcandlestickmodelmapper.cpp candlestickchart/qhcandlestickmodelmapper.h
candlestickchart/qvcandlestickmodelmapper.cpp candlestickchart/qvcandlestickmodelmapper.h
legend/qcandlesticklegendmarker.cpp legend/qcandlesticklegendmarker.h legend/qcandlesticklegendmarker_p.h
+ NO_PCH_SOURCES
+ animations/candlestickanimation.cpp # undef QT_NO_FOREACH
+ candlestickchart/candlestickchartitem.cpp # undef QT_NO_FOREACH
+ candlestickchart/qcandlestickseries.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
candlestickchart
)
@@ -265,6 +308,9 @@ qt_internal_extend_target(Charts CONDITION QT_FEATURE_charts_datetime_axis
axis/datetimeaxis/polarchartdatetimeaxisangular.cpp axis/datetimeaxis/polarchartdatetimeaxisangular_p.h
axis/datetimeaxis/polarchartdatetimeaxisradial.cpp axis/datetimeaxis/polarchartdatetimeaxisradial_p.h
axis/datetimeaxis/qdatetimeaxis.cpp axis/datetimeaxis/qdatetimeaxis.h axis/datetimeaxis/qdatetimeaxis_p.h
+ NO_PCH_SOURCES
+ axis/datetimeaxis/chartdatetimeaxisx.cpp # undef QT_NO_FOREACH
+ axis/datetimeaxis/chartdatetimeaxisy.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
axis/datetimeaxis
)
diff --git a/src/charts/animations/boxplotanimation.cpp b/src/charts/animations/boxplotanimation.cpp
index 018fd956..0bb4a5ff 100644
--- a/src/charts/animations/boxplotanimation.cpp
+++ b/src/charts/animations/boxplotanimation.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 <private/boxplotanimation_p.h>
#include <private/boxplotchartitem_p.h>
#include <private/boxwhiskersdata_p.h>
diff --git a/src/charts/animations/candlestickanimation.cpp b/src/charts/animations/candlestickanimation.cpp
index 49ba7215..7c47e03a 100644
--- a/src/charts/animations/candlestickanimation.cpp
+++ b/src/charts/animations/candlestickanimation.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 <private/candlestick_p.h>
#include <private/candlestickanimation_p.h>
#include <private/candlestickbodywicksanimation_p.h>
diff --git a/src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.cpp b/src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.cpp
index 219f03af..d07d7cdc 100644
--- a/src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.cpp
+++ b/src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.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 <private/chartbarcategoryaxisx_p.h>
#include <private/chartpresenter_p.h>
#include <private/qbarcategoryaxis_p.h>
diff --git a/src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.cpp b/src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.cpp
index 78c1c8d8..557a58f7 100644
--- a/src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.cpp
+++ b/src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.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 <private/chartbarcategoryaxisy_p.h>
#include <private/chartpresenter_p.h>
#include <private/qbarcategoryaxis_p.h>
diff --git a/src/charts/axis/barcategoryaxis/qbarcategoryaxis.cpp b/src/charts/axis/barcategoryaxis/qbarcategoryaxis.cpp
index 40432f8a..8eebceb3 100644
--- a/src/charts/axis/barcategoryaxis/qbarcategoryaxis.cpp
+++ b/src/charts/axis/barcategoryaxis/qbarcategoryaxis.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 <QtCharts/QBarCategoryAxis>
#include <private/qbarcategoryaxis_p.h>
#include <private/chartbarcategoryaxisx_p.h>
diff --git a/src/charts/axis/cartesianchartaxis.cpp b/src/charts/axis/cartesianchartaxis.cpp
index 30263754..9f0e8a8e 100644
--- a/src/charts/axis/cartesianchartaxis.cpp
+++ b/src/charts/axis/cartesianchartaxis.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 <QtCharts/qabstractaxis.h>
#include <QtCharts/qlogvalueaxis.h>
#include <QtCharts/qvalueaxis.h>
diff --git a/src/charts/axis/categoryaxis/chartcategoryaxisx.cpp b/src/charts/axis/categoryaxis/chartcategoryaxisx.cpp
index e5efe135..5cbf7905 100644
--- a/src/charts/axis/categoryaxis/chartcategoryaxisx.cpp
+++ b/src/charts/axis/categoryaxis/chartcategoryaxisx.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 <private/chartcategoryaxisx_p.h>
#include <QtCharts/QCategoryAxis>
#include <QtCharts/QAbstractAxis>
diff --git a/src/charts/axis/categoryaxis/chartcategoryaxisy.cpp b/src/charts/axis/categoryaxis/chartcategoryaxisy.cpp
index 9585793a..5ea01bf6 100644
--- a/src/charts/axis/categoryaxis/chartcategoryaxisy.cpp
+++ b/src/charts/axis/categoryaxis/chartcategoryaxisy.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 <private/chartcategoryaxisy_p.h>
#include <QtCharts/QCategoryAxis>
#include <QtCharts/QAbstractAxis>
diff --git a/src/charts/axis/chartaxiselement.cpp b/src/charts/axis/chartaxiselement.cpp
index bfabfa26..affd5415 100644
--- a/src/charts/axis/chartaxiselement.cpp
+++ b/src/charts/axis/chartaxiselement.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2021 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 <private/chartaxiselement_p.h>
#include <private/qabstractaxis_p.h>
#include <private/chartpresenter_p.h>
diff --git a/src/charts/axis/datetimeaxis/chartdatetimeaxisx.cpp b/src/charts/axis/datetimeaxis/chartdatetimeaxisx.cpp
index 386f4603..5c2e4588 100644
--- a/src/charts/axis/datetimeaxis/chartdatetimeaxisx.cpp
+++ b/src/charts/axis/datetimeaxis/chartdatetimeaxisx.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 <private/chartdatetimeaxisx_p.h>
#include <private/chartpresenter_p.h>
#include <QtCharts/QDateTimeAxis>
diff --git a/src/charts/axis/datetimeaxis/chartdatetimeaxisy.cpp b/src/charts/axis/datetimeaxis/chartdatetimeaxisy.cpp
index ffbcea44..5ca050db 100644
--- a/src/charts/axis/datetimeaxis/chartdatetimeaxisy.cpp
+++ b/src/charts/axis/datetimeaxis/chartdatetimeaxisy.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 <private/chartdatetimeaxisy_p.h>
#include <private/chartpresenter_p.h>
#include <QtCharts/QDateTimeAxis>
diff --git a/src/charts/axis/logvalueaxis/chartlogvalueaxisx.cpp b/src/charts/axis/logvalueaxis/chartlogvalueaxisx.cpp
index 93a4da48..ed09ea85 100644
--- a/src/charts/axis/logvalueaxis/chartlogvalueaxisx.cpp
+++ b/src/charts/axis/logvalueaxis/chartlogvalueaxisx.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2021 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 <QtCharts/qlogvalueaxis.h>
#include <QtCore/qmath.h>
#include <QtWidgets/qgraphicslayout.h>
diff --git a/src/charts/axis/logvalueaxis/chartlogvalueaxisy.cpp b/src/charts/axis/logvalueaxis/chartlogvalueaxisy.cpp
index 8a46f8bb..98140029 100644
--- a/src/charts/axis/logvalueaxis/chartlogvalueaxisy.cpp
+++ b/src/charts/axis/logvalueaxis/chartlogvalueaxisy.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2021 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 <QtCharts/qlogvalueaxis.h>
#include <QtCore/qmath.h>
#include <QtWidgets/qgraphicslayout.h>
diff --git a/src/charts/axis/polarchartaxis.cpp b/src/charts/axis/polarchartaxis.cpp
index 930813dc..d8037e73 100644
--- a/src/charts/axis/polarchartaxis.cpp
+++ b/src/charts/axis/polarchartaxis.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 <private/polarchartaxis_p.h>
#include <private/qabstractaxis_p.h>
#include <private/chartpresenter_p.h>
diff --git a/src/charts/axis/polarchartaxisangular.cpp b/src/charts/axis/polarchartaxisangular.cpp
index 2f6269c1..07327b5c 100644
--- a/src/charts/axis/polarchartaxisangular.cpp
+++ b/src/charts/axis/polarchartaxisangular.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 <QtCharts/qcategoryaxis.h>
#include <QtCharts/qlogvalueaxis.h>
#include <QtCore/qmath.h>
diff --git a/src/charts/axis/polarchartaxisradial.cpp b/src/charts/axis/polarchartaxisradial.cpp
index 46d8ca77..80857e4b 100644
--- a/src/charts/axis/polarchartaxisradial.cpp
+++ b/src/charts/axis/polarchartaxisradial.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 <QtCharts/qcategoryaxis.h>
#include <QtCharts/qlogvalueaxis.h>
#include <QtCore/qmath.h>
diff --git a/src/charts/axis/valueaxis/chartvalueaxisx.cpp b/src/charts/axis/valueaxis/chartvalueaxisx.cpp
index dca95be7..2cab9464 100644
--- a/src/charts/axis/valueaxis/chartvalueaxisx.cpp
+++ b/src/charts/axis/valueaxis/chartvalueaxisx.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 <private/chartvalueaxisx_p.h>
#include <QtCharts/QAbstractAxis>
#include <private/chartpresenter_p.h>
diff --git a/src/charts/axis/valueaxis/chartvalueaxisy.cpp b/src/charts/axis/valueaxis/chartvalueaxisy.cpp
index 6d179796..59231df7 100644
--- a/src/charts/axis/valueaxis/chartvalueaxisy.cpp
+++ b/src/charts/axis/valueaxis/chartvalueaxisy.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 <private/chartvalueaxisy_p.h>
#include <QtCharts/QAbstractAxis>
#include <private/chartpresenter_p.h>
diff --git a/src/charts/barchart/abstractbarchartitem.cpp b/src/charts/barchart/abstractbarchartitem.cpp
index ab378a6e..a1c97624 100644
--- a/src/charts/barchart/abstractbarchartitem.cpp
+++ b/src/charts/barchart/abstractbarchartitem.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 <private/abstractbarchartitem_p.h>
#include <private/bar_p.h>
#include <QtCharts/QBarSet>
diff --git a/src/charts/barchart/qabstractbarseries.cpp b/src/charts/barchart/qabstractbarseries.cpp
index d2f09931..0f215761 100644
--- a/src/charts/barchart/qabstractbarseries.cpp
+++ b/src/charts/barchart/qabstractbarseries.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 <QtCharts/QAbstractBarSeries>
#include <private/qabstractbarseries_p.h>
#include <QtCharts/QBarSet>
diff --git a/src/charts/boxplotchart/boxplotchartitem.cpp b/src/charts/boxplotchart/boxplotchartitem.cpp
index 2410899a..4648bddb 100644
--- a/src/charts/boxplotchart/boxplotchartitem.cpp
+++ b/src/charts/boxplotchart/boxplotchartitem.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 <private/boxplotchartitem_p.h>
#include <private/qboxplotseries_p.h>
#include <private/bar_p.h>
diff --git a/src/charts/boxplotchart/qboxplotseries.cpp b/src/charts/boxplotchart/qboxplotseries.cpp
index 8b342c1d..6610327a 100644
--- a/src/charts/boxplotchart/qboxplotseries.cpp
+++ b/src/charts/boxplotchart/qboxplotseries.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 <QtCharts/QBoxPlotSeries>
#include <private/qboxplotseries_p.h>
#include <QtCharts/QBoxPlotLegendMarker>
diff --git a/src/charts/candlestickchart/candlestickchartitem.cpp b/src/charts/candlestickchart/candlestickchartitem.cpp
index 0ff4a093..78b5bb31 100644
--- a/src/charts/candlestickchart/candlestickchartitem.cpp
+++ b/src/charts/candlestickchart/candlestickchartitem.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 <QtCharts/QCandlestickSeries>
#include <QtCharts/QCandlestickSet>
#include <private/candlestickchartitem_p.h>
diff --git a/src/charts/candlestickchart/qcandlestickseries.cpp b/src/charts/candlestickchart/qcandlestickseries.cpp
index dd20163a..d0d93d8c 100644
--- a/src/charts/candlestickchart/qcandlestickseries.cpp
+++ b/src/charts/candlestickchart/qcandlestickseries.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 <QtCharts/QBarCategoryAxis>
#include <QtCharts/QCandlestickLegendMarker>
#include <QtCharts/QCandlestickSeries>
diff --git a/src/charts/chartdataset.cpp b/src/charts/chartdataset.cpp
index 02c5191a..b85262f2 100644
--- a/src/charts/chartdataset.cpp
+++ b/src/charts/chartdataset.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2021 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 <private/chartdataset_p.h>
#include <private/chartpresenter_p.h>
#include <QtCharts/QChart>
diff --git a/src/charts/chartpresenter.cpp b/src/charts/chartpresenter.cpp
index dd156a02..ad07fb68 100644
--- a/src/charts/chartpresenter.cpp
+++ b/src/charts/chartpresenter.cpp
@@ -1,5 +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 <private/chartpresenter_p.h>
#include <QtCharts/QChart>
#include <private/chartitem_p.h>
diff --git a/src/charts/chartthememanager.cpp b/src/charts/chartthememanager.cpp
index f8d5c9dc..b39804a0 100644
--- a/src/charts/chartthememanager.cpp
+++ b/src/charts/chartthememanager.cpp
@@ -1,5 +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 <private/qabstractseries_p.h>
#include <private/qabstractaxis_p.h>
//themes
diff --git a/src/charts/glwidget.cpp b/src/charts/glwidget.cpp
index 93659a0e..87aa8113 100644
--- a/src/charts/glwidget.cpp
+++ b/src/charts/glwidget.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
+
#ifndef QT_NO_OPENGL
#include "private/glwidget_p.h"
diff --git a/src/charts/layout/polarchartlayout.cpp b/src/charts/layout/polarchartlayout.cpp
index 71c56c93..319e4dc2 100644
--- a/src/charts/layout/polarchartlayout.cpp
+++ b/src/charts/layout/polarchartlayout.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 <private/polarchartlayout_p.h>
#include <private/chartpresenter_p.h>
#include <private/polarchartaxis_p.h>
diff --git a/src/charts/legend/legendlayout.cpp b/src/charts/legend/legendlayout.cpp
index 51d08052..7c7fbc83 100644
--- a/src/charts/legend/legendlayout.cpp
+++ b/src/charts/legend/legendlayout.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 <private/legendlayout_p.h>
#include <private/chartpresenter_p.h>
#include <private/qlegend_p.h>
diff --git a/src/charts/legend/qlegend.cpp b/src/charts/legend/qlegend.cpp
index a7062e76..ef94fe0c 100644
--- a/src/charts/legend/qlegend.cpp
+++ b/src/charts/legend/qlegend.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2021 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 <QtCharts/QLegend>
#include <private/qlegend_p.h>
#include <QtCharts/QAbstractSeries>
diff --git a/src/charts/piechart/piechartitem.cpp b/src/charts/piechart/piechartitem.cpp
index d60a8f4a..fb91aec2 100644
--- a/src/charts/piechart/piechartitem.cpp
+++ b/src/charts/piechart/piechartitem.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 <QtCharts/qpieslice.h>
#include <QtCharts/qpieseries.h>
#include <QtWidgets/qgraphicssceneevent.h>
diff --git a/src/charts/piechart/qpieseries.cpp b/src/charts/piechart/qpieseries.cpp
index 1d34555a..a7b1bdf7 100644
--- a/src/charts/piechart/qpieseries.cpp
+++ b/src/charts/piechart/qpieseries.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 <QtCharts/QPieSeries>
#include <private/qpieseries_p.h>
#include <QtCharts/QPieSlice>
diff --git a/src/charts/qchart.cpp b/src/charts/qchart.cpp
index afb98d08..14f95fe0 100644
--- a/src/charts/qchart.cpp
+++ b/src/charts/qchart.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2017 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 <QtCharts/QChart>
#include <private/qchart_p.h>
#include <private/legendscroller_p.h>
diff --git a/src/charts/xychart/glxyseriesdata.cpp b/src/charts/xychart/glxyseriesdata.cpp
index 2c9be34f..3015535b 100644
--- a/src/charts/xychart/glxyseriesdata.cpp
+++ b/src/charts/xychart/glxyseriesdata.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 "private/glxyseriesdata_p.h"
#include "private/abstractdomain_p.h"
#if QT_CONFIG(charts_scatter_chart)
diff --git a/src/charts/xychart/qxyseries.cpp b/src/charts/xychart/qxyseries.cpp
index cebe08e6..7e0101df 100644
--- a/src/charts/xychart/qxyseries.cpp
+++ b/src/charts/xychart/qxyseries.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2022 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 <QtCharts/QXYSeries>
#include <QtCharts/QColorAxis>
#include <private/qxyseries_p.h>