From 3de01e4e64a8c9fbf042d3e5d6a9bf0ecb49e187 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 22 Feb 2024 07:53:17 +0100 Subject: [PATCH] QOperatingSystemVersion: clean up after QOSVBase extraction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When 3446313c7a5cd6005089866a7b20c9f28e132a0a extracted most functions from QOperatingSystemVersion to a new unexported QOperatingSystemVersionBase, for BC reasons, it kept the existing QOSV methods as (inline or out-of-line) forwarders to the new QOSVBase ones. But the only ones that are actually still required are currentType(), type(), and isAnyOfType(), because their Base equivalents use a different enum type (we should probably make the OS Type an enum in namespace Qt instead; other patch). The others can just be REMOVED_SINCE, and should be, to make new code use the base class implementations, where inlining and constexpr properly work (they don't, on Windows, in exported classes). Re-use the existing REMOVED_SINCE(6,3) block in removed_api.cpp to move these functions there. Amends 3446313c7a5cd6005089866a7b20c9f28e132a0a. Reverts a tiny part of 215677818470e48e9090d7ae4411e1fea62207b8 (will conflict in backports). Pick-to: 6.6 6.5 Change-Id: I1d7ba784634ccd7c9ba5f7ceddb15b7787468d31 Reviewed-by: Qt CI Bot Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 1214edc0d94fd8b3c0d2660879d9175256c14bbc) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/compat/removed_api.cpp | 10 ++++++++++ src/corelib/global/qoperatingsystemversion.cpp | 11 +---------- src/corelib/global/qoperatingsystemversion.h | 8 +++++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index 4d6949d4026..983a220da66 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -139,6 +139,16 @@ QLocale::Language QLocale::codeToLanguage(QStringView languageCode) noexcept #include "qoperatingsystemversion.h" +QOperatingSystemVersion QOperatingSystemVersion::current() +{ + return QOperatingSystemVersionBase::current(); +} + +QString QOperatingSystemVersion::name() const +{ + return QOperatingSystemVersionBase::name(); +} + int QOperatingSystemVersion::compare(const QOperatingSystemVersion &v1, const QOperatingSystemVersion &v2) { diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index f09032227b1..780ee6a5305 100644 --- a/src/corelib/global/qoperatingsystemversion.cpp +++ b/src/corelib/global/qoperatingsystemversion.cpp @@ -111,15 +111,11 @@ QT_BEGIN_NAMESPACE */ /*! + \fn QOperatingSystemVersion::current() Returns a QOperatingSystemVersion indicating the current OS and its version number. \sa currentType() */ -QOperatingSystemVersion QOperatingSystemVersion::current() -{ - return QOperatingSystemVersionBase::current(); -} - QOperatingSystemVersionBase QOperatingSystemVersionBase::current() { static const QOperatingSystemVersionBase v = current_impl(); @@ -306,11 +302,6 @@ int QOperatingSystemVersionBase::compare(QOperatingSystemVersionBase v1, \sa type() */ -QString QOperatingSystemVersion::name() const -{ - return QOperatingSystemVersionBase::name(); -} - QString QOperatingSystemVersionBase::name(QOperatingSystemVersionBase osversion) { switch (osversion.type()) { diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h index ef032b6532f..3128c5a4e64 100644 --- a/src/corelib/global/qoperatingsystemversion.h +++ b/src/corelib/global/qoperatingsystemversion.h @@ -236,13 +236,16 @@ public: { } +#if QT_CORE_REMOVED_SINCE(6, 3) || defined(Q_QDOC) static QOperatingSystemVersion current(); +#endif static constexpr OSType currentType() { return OSType(QOperatingSystemVersionBase::currentType()); } +#if QT_CORE_REMOVED_SINCE(6, 3) || defined(Q_QDOC) QVersionNumber version() const { return QOperatingSystemVersionBase::version(); } constexpr int majorVersion() const { return QOperatingSystemVersionBase::majorVersion(); } @@ -251,10 +254,13 @@ public: constexpr int segmentCount() const { return QOperatingSystemVersionBase::segmentCount(); } +#endif // QT_CORE_REMOVED_SINCE(6, 3) constexpr OSType type() const { return OSType(QOperatingSystemVersionBase::type()); } QT7_ONLY(Q_CORE_EXPORT) bool isAnyOfType(std::initializer_list types) const; - QT7_ONLY(Q_CORE_EXPORT) QString name() const; +#if QT_CORE_REMOVED_SINCE(6, 3) || defined(Q_QDOC) + QString name() const; +#endif private: QOperatingSystemVersion() = default;