From 4dc29bc9de1da1d373962dbd4b1d232f38ffeee0 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 12 May 2016 12:33:04 +0200 Subject: 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 Reviewed-by: Thiago Macieira --- src/corelib/io/qdebug.cpp | 11 +++++++++++ src/corelib/io/qdebug.h | 9 +++++++++ src/corelib/tools/qsharedpointer.cpp | 11 ----------- src/corelib/tools/qsharedpointer.h | 2 -- src/corelib/tools/qsharedpointer_impl.h | 11 ----------- 5 files changed, 20 insertions(+), 24 deletions(-) (limited to 'src/corelib') 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 @@ -793,6 +793,17 @@ QDebug &QDebug::resetFormat() Writes \a flag to \a stream. */ +/*! + \fn QDebug operator<<(QDebug debug, const QSharedPointer &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 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 #include #include +#include // all these have already been included by various headers above, but don't rely on indirect includes: #include @@ -330,6 +331,14 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache &cache) return debug.maybeSpace(); } +template +inline QDebug operator<<(QDebug debug, const QSharedPointer &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 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 &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 #include 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 QSharedPointer qSharedPointerObjectCast(const QWe template QWeakPointer qWeakPointerCast(const QWeakPointer &src); -template QDebug operator<<(QDebug debug, const QSharedPointer &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 #include #include // for qobject_cast -#include #if QT_DEPRECATED_SINCE(5, 6) #include #endif @@ -877,16 +876,6 @@ inline void qSwap(QSharedPointer &p1, QSharedPointer &p2) p1.swap(p2); } -#ifndef QT_NO_DEBUG_STREAM -template -Q_INLINE_TEMPLATE QDebug operator<<(QDebug debug, const QSharedPointer &ptr) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QSharedPointer(" << ptr.data() << ")"; - return debug; -} -#endif - QT_END_NAMESPACE namespace std { template -- cgit v1.2.3