[libraries/qxmpp/1.16] src: Utils: Don't include non-installed Algorithms.h from installed header
Linus Jahn <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit a93339e8846c8d4bd65bc0e44dbf08cc3449a38c by Linus Jahn. Committed on 23/07/2026 at 14:02. Pushed by lnj into branch '1.16'. Utils: Don't include non-installed Algorithms.h from installed header QXmppUtils_p.h is an installed header, but it included Algorithms.h, which is intentionally not installed. As a result an installed QXmpp exposes a header that includes a file that is not shipped, breaking builds against the installed headers. Remove the Algorithms.h include from QXmppUtils_p.h by replacing the two transform<>() uses in parseTextElements()/parseSingleAttributeElements() with plain loops (via a small local push_back/insert helper), and add the include directly to the few places that previously relied on getting it transitively. Co-Authored-By: Claude Opus 4.8 <[email protected]> M +1 -0 src/base/Iq.h M +1 -0 src/base/QXmppDataForm.cpp M +1 -0 src/base/QXmppDiscoveryIq.cpp M +1 -0 src/base/QXmppPresence.cpp M +22 -6 src/base/QXmppUtils_p.h M +1 -0 src/client/QXmppPepBookmarkManager.cpp https://invent.kde.org/libraries/qxmpp/-/commit/a93339e8846c8d4bd65bc0e44dbf08cc3449a38c diff --git a/src/base/Iq.h b/src/base/Iq.h index fed5a618..4eecd45d 100644 --- a/src/base/Iq.h +++ b/src/base/Iq.h @@ -10,6 +10,7 @@ #include "QXmppStanza.h" #include "QXmppVisitHelper_p.h" +#include "Algorithms.h" #include "StringLiterals.h" #include "XmlWriter.h" diff --git a/src/base/QXmppDataForm.cpp b/src/base/QXmppDataForm.cpp index d2a3f73e..46e9d1c5 100644 --- a/src/base/QXmppDataForm.cpp +++ b/src/base/QXmppDataForm.cpp @@ -9,6 +9,7 @@ #include "QXmppDataFormBase.h" #include "QXmppUtils_p.h" +#include "Algorithms.h" #include "StringLiterals.h" #include "XmlWriter.h" diff --git a/src/base/QXmppDiscoveryIq.cpp b/src/base/QXmppDiscoveryIq.cpp index 0105403e..da506cd2 100644 --- a/src/base/QXmppDiscoveryIq.cpp +++ b/src/base/QXmppDiscoveryIq.cpp @@ -8,6 +8,7 @@ #include "QXmppConstants_p.h" #include "QXmppUtils_p.h" +#include "Algorithms.h" #include "StringLiterals.h" #include "XmlWriter.h" diff --git a/src/base/QXmppPresence.cpp b/src/base/QXmppPresence.cpp index e479f151..428a2d4f 100644 --- a/src/base/QXmppPresence.cpp +++ b/src/base/QXmppPresence.cpp @@ -12,6 +12,7 @@ #include "QXmppUtils_p.h" #include "QXmppXmlExtensions.h" +#include "Algorithms.h" #include "StringLiterals.h" #include "XmlWriter.h" diff --git a/src/base/QXmppUtils_p.h b/src/base/QXmppUtils_p.h index 5287a14b..2083290e 100644 --- a/src/base/QXmppUtils_p.h +++ b/src/base/QXmppUtils_p.h @@ -9,8 +9,6 @@ #include "QXmppGlobal.h" #include "QXmppXmlTags_p.h" -#include "Algorithms.h" - #include <functional> #include <optional> #include <stdint.h> @@ -226,19 +224,37 @@ auto parseChildElements(const QDomElement &parentEl) -> Container return elements; } +// Append a value to a container regardless of whether it uses push_back() or insert(). +template<typename Container, typename Value> +inline void appendToContainer(Container &container, Value &&value) +{ + if constexpr (requires { container.push_back(std::forward<Value>(value)); }) { + container.push_back(std::forward<Value>(value)); + } else { + container.insert(std::forward<Value>(value)); + } +} + template<typename Container = QList<QString>> auto parseTextElements(const QDomElement &parent, QStringView tagName, QStringView xmlns) -> Container { - return transform<Container>(iterChildElements(parent, tagName, xmlns), &QDomElement::text); + Container result; + for (const auto &el : iterChildElements(parent, tagName, xmlns)) { + appendToContainer(result, el.text()); + } + return result; } template<typename Container = QList<QString>> auto parseSingleAttributeElements(const QDomElement &parent, QStringView tagName, QStringView xmlns, const QString &attribute) + -> Container { - return transform<Container>(iterChildElements(parent, tagName, xmlns), [=](const QDomElement &el) { - return el.attribute(attribute); - }); + Container result; + for (const auto &el : iterChildElements(parent, tagName, xmlns)) { + appendToContainer(result, el.attribute(attribute)); + } + return result; } QByteArray serializeXmlWriter(std::function<void(XmlWriter &)>); diff --git a/src/client/QXmppPepBookmarkManager.cpp b/src/client/QXmppPepBookmarkManager.cpp index c16cf52f..1b6fa2d1 100644 --- a/src/client/QXmppPepBookmarkManager.cpp +++ b/src/client/QXmppPepBookmarkManager.cpp @@ -11,6 +11,7 @@ #include "QXmppPubSubManager.h" #include "QXmppUtils_p.h" +#include "Algorithms.h" #include "Global.h" #include "StringLiterals.h" #include "XmlWriter.h"