From e5c551a5cfc99dd1266514e8a3b4312eaabb95f4 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 9 Apr 2024 12:19:50 +0200 Subject: [PATCH] QtXml: be systematic about feature dom All the actual code of the module was subject to #ifndef QT_NO_DOM, aside from the *_p.h that were only included subject to such #if-ery, so there's nothing left of the module if the feature is ever disabled, but be consistent with the module defining a feature that allows that. Convert #ifndef QT_NO_DOM to #if QT_CONFIG(dom) (and move to outside the namespace, where nothing was inside without the define), require feature dom in the *_p.h and test, change CMake config to skip the test when the feature is disabled (and add a missing SPDX comment), condition including sources on the feature. Pick-to: 6.7 6.5 Task-number: QTBUG-122619 Change-Id: Ie2167b6c56d96c7804785e225f3fe02dbc78984c Reviewed-by: Alexey Edelev Reviewed-by: Volker Hilsheimer (cherry picked from commit a4c85a5cf19d8919797aba41077bfa8796427f54) Reviewed-by: Qt Cherry-pick Bot --- src/xml/CMakeLists.txt | 10 ++++++---- src/xml/dom/qdom.cpp | 4 ++-- src/xml/dom/qdom.h | 9 ++++----- src/xml/dom/qdom_p.h | 1 + src/xml/dom/qdomhelpers.cpp | 4 ++-- src/xml/dom/qdomhelpers_p.h | 1 + tests/auto/xml/CMakeLists.txt | 5 ++++- tests/auto/xml/dom/qdom/tst_qdom.cpp | 1 + 8 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index e0c31eeabd9..65e13db7e7e 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -7,8 +7,6 @@ qt_internal_add_module(Xml SOURCES - dom/qdom.cpp dom/qdom.h dom/qdom_p.h - dom/qdomhelpers.cpp dom/qdomhelpers_p.h qtxmlglobal.h DEFINES QT_NO_CONTEXTLESS_CONNECT @@ -23,13 +21,17 @@ qt_internal_add_module(Xml Qt::CorePrivate ) -## Scopes: -##################################################################### +qt_internal_extend_target(Xml CONDITION QT_FEATURE_dom + SOURCES + dom/qdom.cpp dom/qdom.h dom/qdom_p.h + dom/qdomhelpers.cpp dom/qdomhelpers_p.h +) qt_internal_extend_target(Xml CONDITION MSVC AND (TEST_architecture_arch STREQUAL "i386") LINK_OPTIONS "/BASE:0x61000000" ) + qt_internal_add_docs(Xml doc/qtxml.qdocconf ) diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index a9c2a648582..043fd3a6855 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -5,7 +5,7 @@ #include #include "private/qxmlutils_p.h" -#ifndef QT_NO_DOM +#if QT_CONFIG(dom) #include "qdom_p.h" #include "qdomhelpers_p.h" @@ -6983,4 +6983,4 @@ QDomComment QDomNode::toComment() const QT_END_NAMESPACE -#endif // QT_NO_DOM +#endif // feature dom diff --git a/src/xml/dom/qdom.h b/src/xml/dom/qdom.h index a3900609c40..0ac7d9130e9 100644 --- a/src/xml/dom/qdom.h +++ b/src/xml/dom/qdom.h @@ -7,13 +7,12 @@ #include #include +#if QT_CONFIG(dom) + class tst_QDom; QT_BEGIN_NAMESPACE - -#ifndef QT_NO_DOM - class QIODevice; class QTextStream; @@ -666,8 +665,8 @@ private: Q_XML_EXPORT QTextStream& operator<<(QTextStream& stream, const QDomNode& node); -#endif // QT_NO_DOM - QT_END_NAMESPACE +#endif // feature dom + #endif // QDOM_H diff --git a/src/xml/dom/qdom_p.h b/src/xml/dom/qdom_p.h index b2ecd534c88..2a8e2deac0c 100644 --- a/src/xml/dom/qdom_p.h +++ b/src/xml/dom/qdom_p.h @@ -11,6 +11,7 @@ #include #include +QT_REQUIRE_CONFIG(dom); QT_BEGIN_NAMESPACE // diff --git a/src/xml/dom/qdomhelpers.cpp b/src/xml/dom/qdomhelpers.cpp index 0649e0c75d8..c41529f289d 100644 --- a/src/xml/dom/qdomhelpers.cpp +++ b/src/xml/dom/qdomhelpers.cpp @@ -3,7 +3,7 @@ #include -#ifndef QT_NO_DOM +#if QT_CONFIG(dom) #include "qdomhelpers_p.h" #include "qdom_p.h" @@ -442,4 +442,4 @@ bool QDomParser::parseMarkupDecl() QT_END_NAMESPACE -#endif // QT_NO_DOM +#endif // feature dom diff --git a/src/xml/dom/qdomhelpers_p.h b/src/xml/dom/qdomhelpers_p.h index 5a4b2207f9a..6a27fe09d0d 100644 --- a/src/xml/dom/qdomhelpers_p.h +++ b/src/xml/dom/qdomhelpers_p.h @@ -7,6 +7,7 @@ #include #include +QT_REQUIRE_CONFIG(dom); QT_BEGIN_NAMESPACE // diff --git a/tests/auto/xml/CMakeLists.txt b/tests/auto/xml/CMakeLists.txt index 92ac1870f69..6c770d18eb6 100644 --- a/tests/auto/xml/CMakeLists.txt +++ b/tests/auto/xml/CMakeLists.txt @@ -1,3 +1,6 @@ # Copyright (C) 2024 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -add_subdirectory(dom) + +if(QT_FEATURE_dom) + add_subdirectory(dom) +endif() diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index b73dbc49e27..d77ecc811d8 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -17,6 +17,7 @@ #include #include +QT_REQUIRE_CONFIG(dom); QT_FORWARD_DECLARE_CLASS(QDomDocument) QT_FORWARD_DECLARE_CLASS(QDomNode)