QtWidgets: clean up API removals

As suggested by Peppe and Lars, use one file per module to hold the
removed functions, not one per major version and subdir. Also, make
the remove macro more like QT_DEPRECATED_SINCE.

Change-Id: I2ade51ccc8cb8720ece493936775dfd3b5d438d7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Marc Mutz 2021-07-13 16:53:03 +02:00
parent 8c49ae522d
commit 0c8b98774c
5 changed files with 43 additions and 7 deletions

View File

@ -440,6 +440,42 @@ 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 <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

@ -8,6 +8,7 @@ qt_internal_add_module(Widgets
QMAKE_MODULE_CONFIG uic
PLUGIN_TYPES styles
SOURCES
compat/removed_api.cpp
itemviews/qfileiconprovider.cpp itemviews/qfileiconprovider.h itemviews/qfileiconprovider_p.h
kernel/qapplication.cpp kernel/qapplication.h kernel/qapplication_p.h
kernel/qboxlayout.cpp kernel/qboxlayout.h
@ -47,7 +48,6 @@ qt_internal_add_module(Widgets
widgets/qabstractscrollarea.cpp widgets/qabstractscrollarea.h widgets/qabstractscrollarea_p.h
widgets/qfocusframe.cpp widgets/qfocusframe.h
widgets/qframe.cpp widgets/qframe.h widgets/qframe_p.h
widgets/qtwidgets_widgets_removed_functions_in_6_3.cpp
widgets/qwidgetanimator.cpp widgets/qwidgetanimator_p.h
DEFINES
QT_NO_USING_NAMESPACE
@ -239,7 +239,7 @@ set(qstyle_resource_files
)
set(widgets_no_pch_sources
widgets/qtwidgets_widgets_removed_functions_in_6_3.cpp
compat/removed_api.cpp
)
foreach(src ${widgets_no_pch_sources})

View File

@ -37,13 +37,13 @@
**
****************************************************************************/
#define QT_BUILD_FUNCTIONS_REMOVED_IN_6_3
#define QT_BUILD_REMOVED_API
#include "qglobal.h"
QT_USE_NAMESPACE
#if QT_DEPRECATED_SINCE(6, 3)
#if QT_REMOVED_SINCE(6, 3)
#include "qmenu.h"
@ -99,4 +99,4 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
// #include <qotherheader.h>
// // implement removed functions from qotherheader.h
#endif // QT_DEPRECATED_SINCE(6, 3)
#endif // QT_REMOVED_SINCE(6, 3)

View File

@ -76,7 +76,7 @@ public:
~QMenu();
using QWidget::addAction;
#ifdef QT_BUILD_FUNCTIONS_REMOVED_IN_6_3
#if QT_REMOVED_SINCE(6, 3)
QAction *addAction(const QString &text);
QAction *addAction(const QIcon &icon, const QString &text);
#if !QT_CONFIG(shortcut)

View File

@ -90,7 +90,7 @@ public:
void clear();
using QWidget::addAction;
#ifdef QT_BUILD_FUNCTIONS_REMOVED_IN_6_3
#if QT_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);