diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2016-05-12 12:33:04 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2016-05-12 16:41:32 +0000 |
commit | 4dc29bc9de1da1d373962dbd4b1d232f38ffeee0 (patch) | |
tree | e508e0ada0d59d24d31aee15878774e4b9065314 | |
parent | 99ca47101471023361eef1764a29f085c288347c (diff) |
QSharedPointer: move QDebug stream operators into qdebug.h
In order to avoid pulling in QDebug when including QSharedPointer.
Change-Id: I14b86d1f100ed44a68258c91bbda394b655bac83
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/io/qdebug.cpp | 11 | ||||
-rw-r--r-- | src/corelib/io/qdebug.h | 9 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer.cpp | 11 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 11 |
5 files changed, 20 insertions, 24 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index ffa7867d18..0d9fdb3453 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -794,6 +794,17 @@ QDebug &QDebug::resetFormat() */ /*! + \fn QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr) + \relates QSharedPointer + \since 5.7 + + Writes the pointer tracked by \a ptr into the debug object \a debug for + debugging purposes. + + \sa {Debugging Techniques} +*/ + +/*! \class QDebugStateSaver \inmodule QtCore \brief Convenience class for custom QDebug operators diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 5087e3b532..8021f29e16 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -51,6 +51,7 @@ #include <QtCore/qvector.h> #include <QtCore/qset.h> #include <QtCore/qcontiguouscache.h> +#include <QtCore/qsharedpointer.h> // all these have already been included by various headers above, but don't rely on indirect includes: #include <vector> @@ -330,6 +331,14 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache) return debug.maybeSpace(); } +template <class T> +inline QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "QSharedPointer(" << ptr.data() << ")"; + return debug; +} + Q_CORE_EXPORT void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, int value); template <typename Int> diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index d03e3129aa..84afb0c5db 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1299,17 +1299,6 @@ compile. Use qSharedPointerConstCast to cast away the constness. */ -/*! - \fn QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr) - \relates QSharedPointer - \since 5.7 - - Writes the pointer tracked by \a ptr into the debug object \a debug for - debugging purposes. - - \sa {Debugging Techniques} -*/ - #include <qset.h> #include <qmutex.h> diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h index 901862e7a2..72976637d5 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -159,8 +159,6 @@ template <class X, class T> QSharedPointer<X> qSharedPointerObjectCast(const QWe template <class X, class T> QWeakPointer<X> qWeakPointerCast(const QWeakPointer<T> &src); -template <class T> QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr); - QT_END_NAMESPACE #endif // Q_QDOC diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 6a5c8f4fe5..e9a5443121 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -62,7 +62,6 @@ QT_END_NAMESPACE #include <new> #include <QtCore/qatomic.h> #include <QtCore/qobject.h> // for qobject_cast -#include <QtCore/qdebug.h> #if QT_DEPRECATED_SINCE(5, 6) #include <QtCore/qhash.h> #endif @@ -877,16 +876,6 @@ inline void qSwap(QSharedPointer<T> &p1, QSharedPointer<T> &p2) p1.swap(p2); } -#ifndef QT_NO_DEBUG_STREAM -template <class T> -Q_INLINE_TEMPLATE QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QSharedPointer(" << ptr.data() << ")"; - return debug; -} -#endif - QT_END_NAMESPACE namespace std { template <class T> |