summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-01-31 11:10:26 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-02-01 11:47:58 +0000
commit0d9f4e7526fbf1e072aa3518e4e5313332ee4f18 (patch)
tree3d7c3a6851358c9ee87ba62b1f26cf8c1574ac37
parent2628e897fe3738ee86dacccea72e4a5b6aed9715 (diff)
Make one QT_REMOVED_SINCE/QT_BUILD_REMOVED_API per module
A single global QT_REMOVED_SINCE will start hurting us once more modules downstream of QtCore start using the mechanism. With every use of feature, the set of code that needs to compile under QT_BUILD_REMOVED_API increases. Since we use QT_REMOVED_SINCE in situations where overloading the new and the old function don't work in general, this means all code included by any removed_api.cpp needs to be very carefully written to ensure that any calls to the overload set formed by the combination of old and new function(s) don't create ambiguities. Likewise, the set of APIs that change semantics under QT_BUILD_REMOVED_API also increases. At some point, the combination of removed_api.cpp including almost every module header and almost every header exposing source-incompatibilities when included in removed_api.cpp will make maintenance a headache. By making QT_REMOVED_SINCE and QT_BUILD_REMOVED_API per-module (QT_CORE_REMOVED_SINCE, ...), easy now that we generate the export macros using CMake, we limit the scope of this problem to the module using the feature. Downstream modules (say, QtWidgets) will now see the QtCore API like every other user, even in the widgets/compat/removed_api.cpp TU. Pick-to: 6.3 Change-Id: I177bc7bd5aa8791639f97946c98e4592d2c7f9d9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--cmake/modulecppexports.h.in6
-rw-r--r--src/corelib/compat/removed_api.cpp14
-rw-r--r--src/corelib/global/qglobal.h36
-rw-r--r--src/corelib/global/qoperatingsystemversion.h2
-rw-r--r--src/corelib/kernel/qmetatype.h2
-rw-r--r--src/corelib/plugin/quuid.h4
-rw-r--r--src/corelib/text/qbytearraylist.h2
-rw-r--r--src/corelib/text/qbytearraymatcher.h4
-rw-r--r--src/corelib/time/qcalendar.h2
-rw-r--r--src/corelib/tools/qcryptographichash.h4
-rw-r--r--src/corelib/tools/qversionnumber.h3
-rw-r--r--src/widgets/compat/removed_api.cpp8
-rw-r--r--src/widgets/widgets/qmenu.h2
-rw-r--r--src/widgets/widgets/qmenubar.h2
-rw-r--r--src/widgets/widgets/qtoolbar.h2
15 files changed, 32 insertions, 61 deletions
diff --git a/cmake/modulecppexports.h.in b/cmake/modulecppexports.h.in
index 68b0353a97..ace3cd90e0 100644
--- a/cmake/modulecppexports.h.in
+++ b/cmake/modulecppexports.h.in
@@ -52,4 +52,10 @@
# define Q_@module_define_infix@_EXPORT
#endif
+#ifdef QT_@module_define_infix@_BUILD_REMOVED_API
+#define QT_@module_define_infix@_REMOVED_SINCE(major, minor) QT_DEPRECATED_SINCE(major, minor)
+#else
+#define QT_@module_define_infix@_REMOVED_SINCE(major, minor) 0
+#endif
+
#endif // @header_base_name_upper@_H
diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp
index d21813bbac..fda9a3fe72 100644
--- a/src/corelib/compat/removed_api.cpp
+++ b/src/corelib/compat/removed_api.cpp
@@ -37,13 +37,13 @@
**
****************************************************************************/
-#define QT_BUILD_REMOVED_API
+#define QT_CORE_BUILD_REMOVED_API
#include "qglobal.h"
QT_USE_NAMESPACE
-#if QT_REMOVED_SINCE(6, 1)
+#if QT_CORE_REMOVED_SINCE(6, 1)
#include "qmetatype.h"
@@ -58,9 +58,9 @@ int QMetaType::id() const
return 0;
}
-#endif // QT_REMOVED_SINCE(6, 1)
+#endif // QT_CORE_REMOVED_SINCE(6, 1)
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_CORE_REMOVED_SINCE(6, 3)
#include "qbytearraymatcher.h"
@@ -141,9 +141,9 @@ int QOperatingSystemVersion::compare(const QOperatingSystemVersion &v1,
return QOperatingSystemVersionBase::compare(v1, v2);
}
-#endif // QT_REMOVED_SINCE(6, 3)
+#endif // QT_CORE_REMOVED_SINCE(6, 3)
-#if QT_REMOVED_SINCE(6, 4)
+#if QT_CORE_REMOVED_SINCE(6, 4)
#include "qcalendar.h"
@@ -178,4 +178,4 @@ QT_WARNING_POP
// #include <qotherheader.h>
// // implement removed functions from qotherheader.h
-#endif // QT_REMOVED_SINCE(6, 4)
+#endif // QT_CORE_REMOVED_SINCE(6, 4)
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index ad771d4f5f..864e3b1d87 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -447,42 +447,6 @@ typedef double qreal;
#define QT_DEPRECATED_VERSION_5(minor) QT_DEPRECATED_VERSION_5_##minor
#define QT_DEPRECATED_VERSION(major, minor) QT_DEPRECATED_VERSION_##major##_##minor
-/*
- QT_REMOVED_SINCE(major, minor) evaluates as true if the Qt version is greater than
- the deprecation point specified \e and QT_BUILD_REMOVED_API is defined.
-
- Use it to remove functions from the API, but not the ABI, by moving their definitions
- into the module's \c{removed_api/} subdir and defining QT_BUILD_REMOVED_API.
-
- Example:
-
- // header
- #if QT_REMOVED_SINCE(6, 3)
- void removedFunction(); // function removed since Qt 6.3
- #endif
-
- // implementation
- // ... moved from here ...
-
- // removed_api/some.cpp
- #define QT_BUILD_REMOVED_API
- #include <QtCore/qglobal.h>
-
- #include <someheader.h>
-
- #if QT_REMOVED_SINCE(6, 3)
- void removedFunction() { newFunction(); }
- #endif
-
- The function is now removed from the API, but remains in the ABI until
- the deprecation point moves past 6.3.
-*/
-#ifdef QT_BUILD_REMOVED_API
-#define QT_REMOVED_SINCE(major, minor) QT_DEPRECATED_SINCE(major, minor)
-#else
-#define QT_REMOVED_SINCE(major, minor) 0
-#endif
-
#ifdef __cplusplus
// A tag to help mark stuff deprecated (cf. QStringViewLiteral)
namespace QtPrivate {
diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h
index 92e2848e2c..31bfadb9e0 100644
--- a/src/corelib/global/qoperatingsystemversion.h
+++ b/src/corelib/global/qoperatingsystemversion.h
@@ -265,7 +265,7 @@ public:
private:
QOperatingSystemVersion() = default;
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_CORE_REMOVED_SINCE(6, 3)
// ### Qt 7: Remove. It's only here for backwards compat with previous inline calls.
[[maybe_unused]] static int compare(const QOperatingSystemVersion &v1,
const QOperatingSystemVersion &v2);
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 62798f4cc8..36de60c1b1 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -445,7 +445,7 @@ public:
bool isValid() const;
bool isRegistered() const;
-#if QT_REMOVED_SINCE(6, 1) || defined(Q_QDOC)
+#if QT_CORE_REMOVED_SINCE(6, 1) || defined(Q_QDOC)
int id() const;
#else
// ### Qt 7: Remove traces of out of line version
diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h
index 9229d5b694..cac6913d6b 100644
--- a/src/corelib/plugin/quuid.h
+++ b/src/corelib/plugin/quuid.h
@@ -100,7 +100,7 @@ public:
explicit QUuid(QAnyStringView string) noexcept
: QUuid{fromString(string)} {}
static QUuid fromString(QAnyStringView string) noexcept;
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_CORE_REMOVED_SINCE(6, 3)
explicit QUuid(const QString &);
static QUuid fromString(QStringView string) noexcept;
static QUuid fromString(QLatin1String string) noexcept;
@@ -110,7 +110,7 @@ public:
QString toString(StringFormat mode = WithBraces) const;
QByteArray toByteArray(StringFormat mode = WithBraces) const;
QByteArray toRfc4122() const;
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_CORE_REMOVED_SINCE(6, 3)
static QUuid fromRfc4122(const QByteArray &);
#endif
static QUuid fromRfc4122(QByteArrayView) noexcept;
diff --git a/src/corelib/text/qbytearraylist.h b/src/corelib/text/qbytearraylist.h
index de5546c8ce..aaf3b4b116 100644
--- a/src/corelib/text/qbytearraylist.h
+++ b/src/corelib/text/qbytearraylist.h
@@ -58,7 +58,7 @@ typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
#ifndef Q_CLANG_QDOC
namespace QtPrivate {
-#if QT_REMOVED_SINCE(6, 3) && QT_POINTER_SIZE != 4
+#if QT_CORE_REMOVED_SINCE(6, 3) && QT_POINTER_SIZE != 4
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
#endif
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *sep, qsizetype len);
diff --git a/src/corelib/text/qbytearraymatcher.h b/src/corelib/text/qbytearraymatcher.h
index 4aac69f30a..581b3c34a5 100644
--- a/src/corelib/text/qbytearraymatcher.h
+++ b/src/corelib/text/qbytearraymatcher.h
@@ -65,7 +65,7 @@ public:
void setPattern(const QByteArray &pattern);
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_CORE_REMOVED_SINCE(6, 3)
qsizetype indexIn(const QByteArray &ba, qsizetype from = 0) const;
#else
Q_WEAK_OVERLOAD
@@ -107,7 +107,7 @@ protected:
// compiler-generated copy/more ctors/assignment operators are ok!
~QStaticByteArrayMatcherBase() = default;
-#if QT_REMOVED_SINCE(6, 3) && QT_POINTER_SIZE != 4
+#if QT_CORE_REMOVED_SINCE(6, 3) && QT_POINTER_SIZE != 4
Q_CORE_EXPORT int indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const noexcept;
#endif
Q_CORE_EXPORT qsizetype indexOfIn(const char *needle, size_t nlen,
diff --git a/src/corelib/time/qcalendar.h b/src/corelib/time/qcalendar.h
index adfbc66ffb..853b45b2a9 100644
--- a/src/corelib/time/qcalendar.h
+++ b/src/corelib/time/qcalendar.h
@@ -146,7 +146,7 @@ public:
explicit QCalendar(); // Gregorian, optimised
explicit QCalendar(System system);
-#if QT_REMOVED_SINCE(6, 4)
+#if QT_CORE_REMOVED_SINCE(6, 4)
explicit QCalendar(QLatin1String name);
explicit QCalendar(QStringView name);
#endif
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index 83aed7c64c..3f586055b1 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -108,7 +108,7 @@ public:
QT_DEPRECATED_VERSION_X_6_4("Use the QByteArrayView overload instead")
void addData(const char *data, qsizetype length);
#endif
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_CORE_REMOVED_SINCE(6, 3)
void addData(const QByteArray &data);
#endif
void addData(QByteArrayView data) noexcept;
@@ -117,7 +117,7 @@ public:
QByteArray result() const;
QByteArrayView resultView() const noexcept;
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_CORE_REMOVED_SINCE(6, 3)
static QByteArray hash(const QByteArray &data, Algorithm method);
#endif
static QByteArray hash(QByteArrayView data, Algorithm method);
diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h
index 3bdfdcd7f8..559a09d750 100644
--- a/src/corelib/tools/qversionnumber.h
+++ b/src/corelib/tools/qversionnumber.h
@@ -304,7 +304,8 @@ public:
}
#endif
-#if QT_REMOVED_SINCE(6, 4)
+
+#if QT_CORE_REMOVED_SINCE(6, 4)
[[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex);
[[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex);
[[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex);
diff --git a/src/widgets/compat/removed_api.cpp b/src/widgets/compat/removed_api.cpp
index 32f4e7c806..173cd5c4bf 100644
--- a/src/widgets/compat/removed_api.cpp
+++ b/src/widgets/compat/removed_api.cpp
@@ -37,13 +37,13 @@
**
****************************************************************************/
-#define QT_BUILD_REMOVED_API
+#define QT_WIDGETS_BUILD_REMOVED_API
-#include "qglobal.h"
+#include "qtwidgetsglobal.h"
QT_USE_NAMESPACE
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_WIDGETS_REMOVED_SINCE(6, 3)
#include "qmenu.h"
@@ -111,4 +111,4 @@ QAction *QMenuBar::addAction(const QString &text, const QObject *receiver, const
// #include <qotherheader.h>
// // implement removed functions from qotherheader.h
-#endif // QT_REMOVED_SINCE(6, 3)
+#endif // QT_WIDGETS_REMOVED_SINCE(6, 3)
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 1b14263e6b..ef5bdf7236 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -76,7 +76,7 @@ public:
~QMenu();
using QWidget::addAction;
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_WIDGETS_REMOVED_SINCE(6, 3)
QAction *addAction(const QString &text);
QAction *addAction(const QIcon &icon, const QString &text);
#if !QT_CONFIG(shortcut)
diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h
index 43bcd39f71..9763954f82 100644
--- a/src/widgets/widgets/qmenubar.h
+++ b/src/widgets/widgets/qmenubar.h
@@ -64,7 +64,7 @@ public:
~QMenuBar();
using QWidget::addAction;
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_WIDGETS_REMOVED_SINCE(6, 3)
QAction *addAction(const QString &text);
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
#endif
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index 09f639d3e7..66c191831d 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -90,7 +90,7 @@ public:
void clear();
using QWidget::addAction;
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_WIDGETS_REMOVED_SINCE(6, 3)
QAction *addAction(const QString &text);
QAction *addAction(const QIcon &icon, const QString &text);
QAction *addAction(const QString &text, const QObject *receiver, const char* member);