From af2daafde72db02454d24b7d691aa6861525ab99 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 18 Nov 2019 17:01:26 +0100 Subject: 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 --- src/corelib/global/qflags.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/corelib/global/qflags.h') 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::value), "QFlags is only usable on enumeration types."); +#if QT_DEPRECATED_SINCE(5,15) struct Private; typedef int (Private::*Zero); +#endif template friend QDataStream &operator>>(QDataStream &, QFlags &); template friend QDataStream &operator<<(QDataStream &, QFlags); 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 flags) noexcept -- cgit v1.2.3