diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-03-09 11:56:56 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-03 22:36:06 +0200 |
commit | b1d6af35a45860ad9dfbd65979ca1df44abae446 (patch) | |
tree | 14799b08495c939de951519c823227d734fab496 /src/corelib | |
parent | e3a8e242ada146b1ec796424696e6c3964ab36dc (diff) |
QWeakPointer: add member-swap
[ChangeLog][QtCore][QWeakPointer] Added member-swap function.
Change-Id: Ide3672dc74a9d8153e5f930290d938e8c23993b5
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qsharedpointer.cpp | 8 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 6 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 19c88fcf1c..2ced3d6a7c 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -771,6 +771,14 @@ */ /*! + \fn void QWeakPointer::swap(QWeakPointer<T> &other) + \since 5.4 + + Swaps this weak pointer instance with \a other. This function is + very fast and never fails. +*/ + +/*! \fn bool QWeakPointer::isNull() const Returns \c true if this object is holding a reference to a null diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h index ea9b4fbf27..d9de48b7f4 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -122,6 +122,8 @@ public: QWeakPointer(const QObject *other); QWeakPointer<T> operator=(const QObject *other); + void swap(QWeakPointer<T> &other); + T *data() const; void clear(); diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index e59efce7ae..f70e398cfe 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -587,6 +587,12 @@ public: return *this; } + inline void swap(QWeakPointer &other) + { + qSwap(this->d, other.d); + qSwap(this->value, other.value); + } + inline QWeakPointer(const QSharedPointer<T> &o) : d(o.d), value(o.data()) { if (d) d->weakref.ref();} inline QWeakPointer &operator=(const QSharedPointer<T> &o) |