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>
This commit is contained in:
Giuseppe D'Angelo 2016-05-12 12:33:04 +02:00
parent 99ca471014
commit 4dc29bc9de
5 changed files with 20 additions and 24 deletions

View File

@ -793,6 +793,17 @@ QDebug &QDebug::resetFormat()
Writes \a flag to \a stream.
*/
/*!
\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

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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>