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>
This commit is contained in:
Marc Mutz 2022-01-31 11:10:26 +01:00
parent 2628e897fe
commit 0d9f4e7526
15 changed files with 32 additions and 61 deletions

View File

@ -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

View File

@ -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)

View File

@ -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 {

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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,

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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);