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; };