diff options
| author | Thiago Macieira <thiago.macieira@intel.com> | 2016-04-14 16:23:22 -0700 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@kdab.com> | 2016-04-28 12:58:35 +0000 |
| commit | e22a230a039a392e71322cb63610d07885a45168 (patch) | |
| tree | 8d7ccb0c1ae14e14daec0d87e14c7fb4fa1b29ec /src/corelib/tools/qsharedpointer.cpp | |
| parent | a7e3c17e755881aa3169a2bb662338bbd2c67512 (diff) | |
| download | qtbase-e22a230a039a392e71322cb63610d07885a45168.tar.gz | |
Make QSharedPointer without custom deleters call the correct destructor
Where "correct" is defined by what std::shared_ptr does as well as what
happens when an intermediate QSharedPointer of the exact type of the
constructor behaves
That is,
QSharedPointer<X> ptr(new Y);
Behaves like
QSharedPointer<X> ptr;
{ QSharedPointer<Y> tmp(new Y); ptr = tmp; }
Change-Id: Id75834dab9ed466e94c7ffff14455d445f72592b
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/tools/qsharedpointer.cpp')
| -rw-r--r-- | src/corelib/tools/qsharedpointer.cpp | 8 |
1 files changed, 8 insertions, 0 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 = |
