From 6daea46918d95ed6b66eaea22e1f72658a1f997b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 23 May 2012 19:46:39 +0200 Subject: [PATCH] Use the copy & swap trick to simplify some code in QSharedPointer Change-Id: I5fa2fae19126bea60b9682ed7765681dd6da8c15 Reviewed-by: Lars Knoll --- src/corelib/tools/qsharedpointer_impl.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 6dc5764e87..db4a0587d2 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -305,13 +305,14 @@ public: { if (d) ref(); } inline QSharedPointer &operator=(const QSharedPointer &other) { - internalCopy(other); + QSharedPointer copy(other); + swap(copy); return *this; } #ifdef Q_COMPILER_RVALUE_REFS inline QSharedPointer &operator=(QSharedPointer &&other) { - QSharedPointer::internalSwap(other); + swap(other); return *this; } #endif @@ -372,7 +373,7 @@ public: } #endif - inline void clear() { *this = QSharedPointer(); } + inline void clear() { QSharedPointer copy; swap(copy); } QWeakPointer toWeakRef() const;