Mark the module as free of Q_FOREACH, except where it isn't

The density of Q_FOREACH uses is moderate here, but too high for this
author, unfamiliar with this code, 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). NB: there are none such TUs in this
module.

Created QTBUG-115830 to keep track of this.

Task-number: QTBUG-115830
Change-Id: I68c9394c04af68cab46480153a5601828565461a
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Marc Mutz 2023-08-07 11:31:16 +02:00
parent dce23a8a51
commit 5fbb714cc1
8 changed files with 15 additions and 0 deletions

View File

@ -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")

View File

@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
//! [0]
QLineEdit *lineEdit = static_cast<QLineEdit *>(
qt_find_obj_child(myWidget, "QLineEdit", "my line edit"));

View File

@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include <QtGui>
#include "math.h"

View File

@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include <QtGui>
#include "dragdropmodel.h"

View File

@ -2,6 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QNetworkAccessManager>

View File

@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include <QWebElement>
#include <QWebFrame>
#include "window.h"

View File

@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// 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 <private/qqmljsengine_p.h>
#include <private/qqmljsparser_p.h>
#include <private/qqmljslexer_p.h>

View File

@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// 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.h>
#include <QLibraryInfo>
#include <QDir>