diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-11-18 17:01:26 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-11-20 19:43:38 +0100 |
commit | af2daafde72db02454d24b7d691aa6861525ab99 (patch) | |
tree | b59c47baf8af94a6ace5cbf4338944272e40e32b /src/corelib/global | |
parent | 8bc4ea1e97c138034d08c705a75f75763361400b (diff) |
Deprecate constructing QFlags from a pointer
This was used to support QFlags f = 0 initialization, but with 0 used
as a pointer literal now considered bad form, it had been changed many
places to QFlags f = nullptr, which is meaningless and confusing.
Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qflags.h | 7 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index bd3c219968..4f46de5eaa 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -93,8 +93,10 @@ class QFlags "long long will overflow."); Q_STATIC_ASSERT_X((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types."); +#if QT_DEPRECATED_SINCE(5,15) struct Private; typedef int (Private::*Zero); +#endif template <typename E> friend QDataStream &operator>>(QDataStream &, QFlags<E> &); template <typename E> friend QDataStream &operator<<(QDataStream &, QFlags<E>); public: @@ -115,8 +117,11 @@ public: Q_DECL_CONSTEXPR inline QFlags(const QFlags &other); Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other); #endif + Q_DECL_CONSTEXPR inline QFlags() noexcept : i(0) {} Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {} - Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) noexcept : i(0) {} +#if QT_DEPRECATED_SINCE(5,15) + QT_DEPRECATED_X("Use default constructor instead") Q_DECL_CONSTEXPR inline QFlags(Zero) noexcept : i(0) {} +#endif Q_DECL_CONSTEXPR inline QFlags(QFlag flag) noexcept : i(flag) {} Q_DECL_CONSTEXPR inline QFlags(std::initializer_list<Enum> flags) noexcept diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 4ab5bd2edb..d95cc786ab 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -250,7 +250,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value)); Qt::Alignment type is simply a typedef for QFlags<Qt::AlignmentFlag>. QLabel::setAlignment() takes a Qt::Alignment parameter, which means that any combination of - Qt::AlignmentFlag values, or 0, is legal: + Qt::AlignmentFlag values, or \c{{ }}, is legal: \snippet code/src_corelib_global_qglobal.cpp 0 @@ -318,10 +318,20 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value)); */ /*! + \fn template <typename Enum> QFlags<Enum>::QFlags() + \since 5.15 + + Constructs a QFlags object with no flags set. +*/ + +/*! \fn template <typename Enum> QFlags<Enum>::QFlags(Zero) + \deprecated Constructs a QFlags object with no flags set. The parameter must be a literal 0 value. + + Deprecated, use default constructor instead. */ /*! |