diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-05-23 19:46:39 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-12 20:09:33 +0200 |
commit | 6daea46918d95ed6b66eaea22e1f72658a1f997b (patch) | |
tree | 828e78b3c9bb96482222c1035e18c908900f7123 /src/corelib/tools/qsharedpointer_impl.h | |
parent | 086d6e74d247300a62026ff28564adb0f4bcab3a (diff) |
Use the copy & swap trick to simplify some code in QSharedPointer
Change-Id: I5fa2fae19126bea60b9682ed7765681dd6da8c15
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qsharedpointer_impl.h')
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 7 |
1 files 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<T> &operator=(const QSharedPointer<T> &other) { - internalCopy(other); + QSharedPointer copy(other); + swap(copy); return *this; } #ifdef Q_COMPILER_RVALUE_REFS inline QSharedPointer<T> &operator=(QSharedPointer<T> &&other) { - QSharedPointer<T>::internalSwap(other); + swap(other); return *this; } #endif @@ -372,7 +373,7 @@ public: } #endif - inline void clear() { *this = QSharedPointer<T>(); } + inline void clear() { QSharedPointer copy; swap(copy); } QWeakPointer<T> toWeakRef() const; |