summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-09-29 18:11:23 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-05 10:16:52 +0200
commit54232d6ea98a313390ee8f36bbadadce49ff97f3 (patch)
tree8ee48dfdc289d812787317e17bfa34f6a862d551 /src/corelib/tools
parent099f756ed5462c3b69b72696f8a46efdbfa0c8c2 (diff)
Streamline the template specialization of QESDP's dtor
Declaring and implementing out of line a specialization for QESDP's destructor is needed if we have an implicitly shared type and we want to provide an inline move constructor for it. The code is however a bit heavy on the eyes, and the full implementation for the destructor must be provided (read: copy and pasted) -- the specialization destructor cannot just "reuse" the one from the primary template. This patch adds a few macros to streamline the above, so that we can start using the same pattern in more places. These macros are completely private for the moment being; we don't want to push this solution for our users. Port QPixmap to the new macros. Change-Id: Ia6a51ad988483e44c9d97c0eca2fb003b6bd21e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qshareddata.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index 71f2e17799..ffd4d4cf0b 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -304,6 +304,32 @@ Q_INLINE_TEMPLATE size_t qHash(const QExplicitlySharedDataPointer<T> &ptr, size_
template<typename T> Q_DECLARE_TYPEINFO_BODY(QSharedDataPointer<T>, Q_MOVABLE_TYPE);
template<typename T> Q_DECLARE_TYPEINFO_BODY(QExplicitlySharedDataPointer<T>, Q_MOVABLE_TYPE);
+#define QT_DECLARE_QSDP_SPECIALIZATION_DTOR(Class) \
+ template<> QSharedDataPointer<Class>::~QSharedDataPointer();
+
+#define QT_DECLARE_QSDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro) \
+ template<> ExportMacro QSharedDataPointer<Class>::~QSharedDataPointer();
+
+#define QT_DEFINE_QSDP_SPECIALIZATION_DTOR(Class) \
+ template<> QSharedDataPointer<Class>::~QSharedDataPointer() \
+ { \
+ if (d && !d->ref.deref()) \
+ delete d; \
+ }
+
+#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR(Class) \
+ template<> QExplicitlySharedDataPointer<Class>::~QExplicitlySharedDataPointer();
+
+#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro) \
+ template<> ExportMacro QExplicitlySharedDataPointer<Class>::~QExplicitlySharedDataPointer();
+
+#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class) \
+ template<> QExplicitlySharedDataPointer<Class>::~QExplicitlySharedDataPointer() \
+ { \
+ if (d && !d->ref.deref()) \
+ delete d; \
+ }
+
QT_END_NAMESPACE
#endif // QSHAREDDATA_H