diff options
Diffstat (limited to 'src/corelib/tools/qscopedpointer.h')
-rw-r--r-- | src/corelib/tools/qscopedpointer.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 2155c56e27..dba37dae23 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -83,6 +83,17 @@ struct QScopedPointerPodDeleter static inline void cleanup(void *pointer) { if (pointer) free(pointer); } }; +#ifndef QT_NO_QOBJECT +template <typename T> +struct QScopedPointerObjectDeleteLater +{ + static inline void cleanup(T *pointer) { if (pointer) pointer->deleteLater(); } +}; + +class QObject; +typedef QScopedPointerObjectDeleteLater<QObject> QScopedPointerDeleteLater; +#endif + template <typename T, typename Cleanup = QScopedPointerDeleter<T> > class QScopedPointer { @@ -98,6 +109,19 @@ public: Cleanup::cleanup(oldD); } +#ifdef Q_COMPILER_RVALUE_REFS + inline QScopedPointer(QScopedPointer<T, Cleanup> &&other) + : d(other.take()) + { + } + + inline QScopedPointer<T, Cleanup> &operator=(QScopedPointer<T, Cleanup> &&other) + { + reset(other.take()); + return *this; + } +#endif + inline T &operator*() const { Q_ASSERT(d); |