Long live QT_ENABLE_STRICT_MODE_UP_TO
We already have fine-grained macros to individually disable APIs that we consider "suboptimal" or "dangerous". This commit adds a shortcut for the user to set all such macros in one go. QT_ENABLE_STRICT_MODE_UP_TO is versioned, just like QT_DISABLE_DEPRECATED_UP_TO; the idea is that users should set it to the minimum Qt version they want to support. Also, if QT_DISABLE_DEPRECATED_UP_TO is not set, then QT_ENABLE_STRICT_MODE_UP_TO will set it as well, to the same value. [ChangeLog][QtCore][QtGlobal] Added the QT_ENABLE_STRICT_MODE_UP_TO macro. Change-Id: I5466465986104e047a6a86369928be9294f24ab7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
03baf08d2b
commit
3a6c8e02b6
@ -73,4 +73,15 @@
|
||||
\c foreach would not. But using \c foreach always copies the container,
|
||||
which is usually not cheap for STL containers. If in doubt, prefer
|
||||
\c foreach for Qt containers, and range based \c for for STL ones.
|
||||
|
||||
You can remove the availability of the Qt's \c foreach loop by
|
||||
defining the \c{QT_NO_FOREACH} macro.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro QT_NO_FOREACH
|
||||
\since 6.0
|
||||
|
||||
Defining this macro removes the availability of Qt's \c foreach
|
||||
loop.
|
||||
*/
|
||||
|
@ -310,6 +310,51 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
|
||||
qMove takes an rvalue reference to its parameter \a x, and converts it to an xvalue.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro QT_ENABLE_STRICT_MODE_UP_TO
|
||||
\relates <QtGlobal>
|
||||
\since 6.8
|
||||
|
||||
Defining this macro will disable a number of Qt APIs that are
|
||||
deemed suboptimal or dangerous.
|
||||
|
||||
This macro's value must be set to a Qt version, using
|
||||
\l{QT_VERSION_CHECK}'s encoding. For instance, in order to set it
|
||||
to Qt 6.6, define \c{QT_ENABLE_STRICT_MODE_UP_TO=0x060600}.
|
||||
This will disable only the APIs introduced in versions up to (and
|
||||
including) the specified Qt version.
|
||||
|
||||
If the \l QT_DISABLE_DEPRECATED_UP_TO macro is \e not defined,
|
||||
then QT_ENABLE_STRICT_MODE_UP_TO will define it as well,
|
||||
to the same value.
|
||||
|
||||
This macro should always be set to the minimum Qt version that
|
||||
your project wants to support.
|
||||
|
||||
The APIs disabled by this macro are listed in the table below,
|
||||
together with the minimum value to use in order to disable them.
|
||||
|
||||
\table
|
||||
\header \li Version \li Disabled APIs
|
||||
\row \li 6.0.0 \li \l{foreach-keyword}{foreach} (see \l{QT_NO_FOREACH})
|
||||
\row \li 6.0.0 \li QString constructors from \c{const char *} (see \l{QT_NO_CAST_FROM_ASCII})
|
||||
\row \li 6.0.0 \li QString conversions towards \c{const char *} / QByteArray (see \l{QT_NO_CAST_TO_ASCII})
|
||||
\row \li 6.0.0 \li QByteArray implicit conversions towards \c{const char *} (see \l{QT_NO_CAST_FROM_BYTEARRAY})
|
||||
\row \li 6.0.0 \li QUrl implicit conversions from QString (see \l{QT_NO_URL_CAST_FROM_STRING})
|
||||
\row \li 6.0.0 \li Allowing narrowing conversions in signal-slot connections (see \l{QT_NO_NARROWING_CONVERSIONS_IN_CONNECT})
|
||||
\row \li 6.0.0 \li Java-style iterators for Qt containers
|
||||
\row \li 6.6.0 \li The qExchange() function (see \l{QT_NO_QEXCHANGE})
|
||||
\row \li 6.7.0 \li Overloads of QObject::connect that do not take a context object (see \l{QT_NO_CONTEXTLESS_CONNECT})
|
||||
\row \li 6.8.0 \li The qAsConst() function (see \l{QT_NO_QASCONST})
|
||||
\endtable
|
||||
|
||||
Moreover, individual APIs may also get disabled as part of the
|
||||
setting of QT_DISABLE_DEPRECATED_UP_TO. Please refer to each class'
|
||||
documentation for more details.
|
||||
|
||||
\sa QT_DISABLE_DEPRECATED_UP_TO, QT_NO_KEYWORDS, QT_VERSION_CHECK
|
||||
*/
|
||||
|
||||
namespace QtPrivate {
|
||||
Q_LOGGING_CATEGORY(lcNativeInterface, "qt.nativeinterface")
|
||||
}
|
||||
|
@ -155,4 +155,35 @@ namespace QT_NAMESPACE {}
|
||||
# define QT_END_MOC_NAMESPACE
|
||||
#endif
|
||||
|
||||
/*
|
||||
Strict mode
|
||||
*/
|
||||
#ifdef QT_ENABLE_STRICT_MODE_UP_TO
|
||||
#ifndef QT_DISABLE_DEPRECATED_UP_TO
|
||||
# define QT_DISABLE_DEPRECATED_UP_TO QT_ENABLE_STRICT_MODE_UP_TO
|
||||
#endif
|
||||
|
||||
#if QT_ENABLE_STRICT_MODE_UP_TO >= QT_VERSION_CHECK(6, 0, 0)
|
||||
# define QT_NO_FOREACH
|
||||
# define QT_NO_CAST_FROM_ASCII
|
||||
# define QT_NO_CAST_TO_ASCII
|
||||
# define QT_NO_CAST_FROM_BYTEARRAY
|
||||
# define QT_NO_URL_CAST_FROM_STRING
|
||||
# define QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
|
||||
# define QT_NO_JAVA_STYLE_ITERATORS
|
||||
#endif // 6.0.0
|
||||
|
||||
#if QT_ENABLE_STRICT_MODE_UP_TO >= QT_VERSION_CHECK(6, 6, 0)
|
||||
# define QT_NO_QEXCHANGE
|
||||
#endif // 6.6.0
|
||||
|
||||
#if QT_ENABLE_STRICT_MODE_UP_TO >= QT_VERSION_CHECK(6, 7, 0)
|
||||
# define QT_NO_CONTEXTLESS_CONNECT
|
||||
#endif // 6.7.0
|
||||
|
||||
#if QT_ENABLE_STRICT_MODE_UP_TO >= QT_VERSION_CHECK(6, 8, 0)
|
||||
# define QT_NO_QASCONST
|
||||
#endif // 6.8.0
|
||||
#endif // QT_ENABLE_STRICT_MODE_UP_TO
|
||||
|
||||
#endif /* QTCONFIGMACROS_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user