Remove "delete value" from QSharedPointer
authorThiago Macieira <thiago.macieira@intel.com>
Wed, 23 May 2012 14:10:56 +0000 (16:10 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 12 Jun 2012 18:09:09 +0000 (20:09 +0200)
commit55c6f09b3af5900d9734817b5c4d7ea1920a2644
treebee65d7acd27b9afbbd2346cff03a365f412af38
parent6929fad9d9f98b43330c6d5a0d6b13b34fa90dc2
Remove "delete value" from QSharedPointer

This allows a QSharedPointer to be used in contexts where the class in
question is still forward-declared. This produced a warning in Qt 4 due
to the expansion of the template, even if there was no chance of the
pointer being deleted there (because the reference count could not drop
to zero).

Now, not only is the warning removed, but you can actually have the
reference count drop to zero in a forward-declared class and it will
do the right thing. That's because the deleter function is always
recorded from the point of construction and we're sure that it wasn't
forward-declared.

The unit test for forward-declarations had to be rewritten. The
previous version was passing only because the QSharedPointer object
was created under the "tracking pointers" mode, which causes a custom
deleter to be used in all cases.

Task-number: QTBUG-25819
Change-Id: Ife37a4cea4551d94084b49ee03504dd39b8802c1
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
src/corelib/tools/qsharedpointer_impl.h
tests/auto/corelib/tools/qsharedpointer/forwarddeclaration.cpp [deleted file]
tests/auto/corelib/tools/qsharedpointer/forwarddeclared.cpp
tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h
tests/auto/corelib/tools/qsharedpointer/qsharedpointer.pro
tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp