Skip to content

Commit

Permalink
Long-live QT_REMOVAL_QT7_DEPRECATED_SINCE(major, minor)
Browse files Browse the repository at this point in the history
... 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 <[email protected]>
  • Loading branch information
isolovev committed Nov 28, 2024
1 parent 07c5ff8 commit a13eb28
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/corelib/global/qtdeprecationmarkers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a13eb28

Please sign in to comment.