summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qsharedpointer.cpp8
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h6
2 files changed, 11 insertions, 3 deletions
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index f420c6237b..c369ff8697 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -447,6 +447,11 @@
Creates a QSharedPointer that points to \a ptr. The pointer \a ptr
becomes managed by this QSharedPointer and must not be passed to
another QSharedPointer object or deleted outside this object.
+
+ Since Qt 5.8, when the last reference to this QSharedPointer gets
+ destroyed, \a ptr will be deleted by calling \c X's destructor (even if \c
+ X is not the same as QSharedPointer's template parameter \c T). Previously,
+ the destructor for \c T was called.
*/
/*!
@@ -477,6 +482,9 @@
}
\endcode
+ Note that the custom deleter function will be called with a pointer to type
+ \c X, even if the QSharedPointer template parameter \c T is not the same.
+
It is also possible to specify a member function directly, as in:
\code
QSharedPointer<MyObject> obj =
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index b9b29e926d..bbac2d0327 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -518,15 +518,15 @@ private:
inline void enableSharedFromThis(...) {}
- template <typename Deleter>
- inline void internalConstruct(T *ptr, Deleter deleter)
+ template <typename X, typename Deleter>
+ inline void internalConstruct(X *ptr, Deleter deleter)
{
if (!ptr) {
d = Q_NULLPTR;
return;
}
- typedef QtSharedPointer::ExternalRefCountWithCustomDeleter<T, Deleter> Private;
+ typedef QtSharedPointer::ExternalRefCountWithCustomDeleter<X, Deleter> Private;
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
typename Private::DestroyerFn actualDeleter = &Private::safetyCheckDeleter;
# else