From ee7fa67eb0060b9c794bae4c7b06110c3b9626e0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 25 May 2012 10:31:03 +0200 Subject: Deprecate the use of QWeakPointer to track QObjects. The main problem with using QWeakPointer to track QObjects is that it has API to convert to QSharedPointer, which is undefined behavior. There is no need to overload the meaning of QWeakPointer with QObject tracking. QPointer is more suitable and should be used instead. Because QPointer is implemented in terms of QWeakPointer, we need to add some overloads which are not deprecated. Change-Id: If0333e4800c9fd277629cc69185c9ca3e4e7e81d Reviewed-by: Thiago Macieira --- src/corelib/kernel/qpointer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel/qpointer.h') diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index 5544a59705..88d8225621 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -57,7 +57,7 @@ class QPointerBase protected: inline QPointerBase() : wp() { } - inline QPointerBase(QObject *p) : wp(p) { } + inline QPointerBase(QObject *p) : wp(p, true) { } // compiler-generated copy/move ctor/assignment operators are fine! (even though public) inline ~QPointerBase() { } @@ -65,7 +65,7 @@ protected: { return wp.data(); } inline void assign(QObject *p) - { wp = p; } + { wp.assign(p); } inline bool isNull() const { return wp.isNull(); } -- cgit v1.2.3