diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-05-23 16:10:56 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-12 20:09:09 +0200 |
commit | 55c6f09b3af5900d9734817b5c4d7ea1920a2644 (patch) | |
tree | bee65d7acd27b9afbbd2346cff03a365f412af38 /tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h | |
parent | 6929fad9d9f98b43330c6d5a0d6b13b34fa90dc2 (diff) |
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>
Diffstat (limited to 'tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h')
-rw-r--r-- | tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h b/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h index 23f6dbf24c..604e7fd70d 100644 --- a/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h +++ b/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Intel Corporation. ** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -43,12 +44,17 @@ #define FORWARDDECLARED_H extern int forwardDeclaredDestructorRunCount; -class ForwardDeclared -{ -public: - ~ForwardDeclared(); -}; +class ForwardDeclared; -ForwardDeclared *forwardPointer(); +#ifdef QT_NAMESPACE +namespace QT_NAMESPACE { +#endif +template <typename T> class QSharedPointer; +#ifdef QT_NAMESPACE +} +using namespace QT_NAMESPACE; +#endif + +QSharedPointer<ForwardDeclared> *forwardPointer(); #endif // FORWARDDECLARED_H |