From 70dcbb4f171753cd953cbad0ea77b0a9f6623f07 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 11 Jun 2024 18:14:33 +0200 Subject: [PATCH] QESDP: deprecate QT_ENABLE_QEXPLICITLYSHAREDDATAPOINTER_STATICCAST We've had this workaround since Qt 5.4. It's due time we get rid of it. This commit deprecates it, in preparation for removal. [ChangeLog][QtCore][QExplicitlySharedDataPointer] Support for QT_ENABLE_QEXPLICITLYSHAREDDATAPOINTER_STATICCAST has been deprecated, and will get removed in a future version of Qt. Change-Id: I3000ea606b37714542916e105ebd50871dc42935 Reviewed-by: Volker Hilsheimer (cherry picked from commit 0ed039fd134fb8025236847295681f13f1775847) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qshareddata.cpp | 4 ++++ src/corelib/tools/qshareddata.h | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp index 8ef174ebfcf..3d3e0c782ad 100644 --- a/src/corelib/tools/qshareddata.cpp +++ b/src/corelib/tools/qshareddata.cpp @@ -589,6 +589,10 @@ QT_BEGIN_NAMESPACE \c{QT_ENABLE_QEXPLICITLYSHAREDDATAPOINTER_STATICCAST} macro, and therefore to allow old code (that relied on this feature) to compile without modifications. + + \note Usage of the + \c{QT_ENABLE_QEXPLICITLYSHAREDDATAPOINTER_STATICCAST} macro is + deprecated. The macro will be removed in a future version of Qt. */ /*! \fn template QExplicitlySharedDataPointer& QExplicitlySharedDataPointer::operator=(const QExplicitlySharedDataPointer& o) diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index 4c4153a506c..bb0ef6ad9fa 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -162,7 +162,7 @@ public: Q_NODISCARD_CTOR QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer &o) noexcept #ifdef QT_ENABLE_QEXPLICITLYSHAREDDATAPOINTER_STATICCAST - : d(static_cast(o.data())) + : d(warnIfQExplicitlySharedDataPointerStaticCastMacroDefined(), static_cast(o.data())) #else : d(o.data()) #endif @@ -213,6 +213,11 @@ protected: private: void detach_helper(); +#ifdef QT_ENABLE_QEXPLICITLYSHAREDDATAPOINTER_STATICCAST + [[deprecated("Usage of QT_ENABLE_QEXPLICITLYSHAREDDATAPOINTER_STATICCAST is deprecated.")]] + constexpr void warnIfQExplicitlySharedDataPointerStaticCastMacroDefined() {} +#endif + T *d; };