From a13eb28329b08c53085bc2902c4a99d0758f972c Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 21 Nov 2024 11:27:29 +0100 Subject: [PATCH] Long-live QT_REMOVAL_QT7_DEPRECATED_SINCE(major, minor) ... and QT_REMOVAL_QT8_DEPRECATED_SINCE. Following up on the discussion from the Qt CS 2024 [0], this patch introduces a new macro to mark the deprecated APIs that will be removed in a specific major release. For now, add the macros for Qt 7 and Qt 8. The macro should be used instead of the regular QT_DEPRECATED_SINCE(maj, min) for such type of APIs. The usage is the same, as with the regular macro: #if QT_REMOVAL_QT7_DEPRECATED_SINCE(6, 9) QT_DEPRECATED_VERSION_X_6_9("The reason for the deprecation") void deprecatedFunc(); #endif The macro is basically a combination of QT_DEPRECATED_SINCE and a comparison against a certain Qt major version. [0]: https://wiki.qt.io/QtCS2024_Deprecate Task-number: QTBUG-130024 Change-Id: I8efa1920d9d1524250bb00446aefffae65210340 Reviewed-by: Jarek Kobus --- src/corelib/global/qtdeprecationmarkers.h | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/corelib/global/qtdeprecationmarkers.h b/src/corelib/global/qtdeprecationmarkers.h index eaf3e7d67f4..46124873c85 100644 --- a/src/corelib/global/qtdeprecationmarkers.h +++ b/src/corelib/global/qtdeprecationmarkers.h @@ -64,6 +64,40 @@ QT_BEGIN_NAMESPACE #define QT_DEPRECATED_SINCE(major, minor) 0 #endif +/* + QT_REMOVAL_QT{VER}_DEPRECATED_SINCE(major, minor) + + The macro should be used if the API is deprecated and should be removed + in the {VER} major release. + + The \a major and \a minor parameters specify the deprecation version. + + For now, we provide the macros to remove the deprecated APIs in Qt 7 + and in Qt 8. + + Example: + + \code + #if QT_REMOVAL_QT7_DEPRECATED_SINCE(6, 9) + QT_DEPRECATED_VERSION_X_6_9("The reason for the deprecation") + void deprecatedFunc(); + #endif + \endcode + + The \c {deprecatedFunc()} function is deprecated since Qt 6.9, and will be + completely removed in Qt 7.0. +*/ +#define QT_DEPRECATED_TO_BE_REMOVED_HELPER(dep_major, dep_minor, rem_major) \ + (QT_DEPRECATED_SINCE(dep_major, dep_minor) && (QT_VERSION < QT_VERSION_CHECK(rem_major, 0, 0))) + +// For APIs that should be removed in Qt 7 +#define QT_REMOVAL_QT7_DEPRECATED_SINCE(major, minor) \ + QT_DEPRECATED_TO_BE_REMOVED_HELPER(major, minor, 7) + +// For APIs that should be removed in Qt 8 +#define QT_REMOVAL_QT8_DEPRECATED_SINCE(major, minor) \ + QT_DEPRECATED_TO_BE_REMOVED_HELPER(major, minor, 8) + /* QT_DEPRECATED_VERSION(major, minor) and QT_DEPRECATED_VERSION_X(major, minor, text) outputs a deprecation warning if QT_WARN_DEPRECATED_UP_TO is equal to or greater