Use QDebugStateSaver to restore space setting in stream operators.
Returning dbg.space() breaks formatting on streams that already have nospace() set. Change-Id: I55e38b018679a67eb40be6b4664505483a3a7d8e Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
c7b003ea3b
commit
3203ac3f4e
@ -395,8 +395,9 @@ QString QDBusError::errorString(ErrorType error)
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QDBusError &msg)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QDBusError(" << msg.name() << ", " << msg.message() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -91,18 +91,20 @@ static inline QString dbusInterfaceString()
|
||||
|
||||
static inline QDebug operator<<(QDebug dbg, const QThread *th)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QThread(ptr=" << (const void*)th;
|
||||
if (th && !th->objectName().isEmpty())
|
||||
dbg.nospace() << ", name=" << th->objectName();
|
||||
else if (th)
|
||||
dbg.nospace() << ", name=" << th->metaObject()->className();
|
||||
dbg.nospace() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
#if QDBUS_THREAD_DEBUG
|
||||
static inline QDebug operator<<(QDebug dbg, const QDBusConnectionPrivate *conn)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QDBusConnection("
|
||||
<< "ptr=" << (const void*)conn
|
||||
<< ", name=" << conn->name
|
||||
@ -113,7 +115,7 @@ static inline QDebug operator<<(QDebug dbg, const QDBusConnectionPrivate *conn)
|
||||
else
|
||||
dbg.nospace() << conn->thread();
|
||||
dbg.nospace() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate *conn)
|
||||
|
@ -785,6 +785,7 @@ static void debugVariantList(QDebug dbg, const QVariantList &list)
|
||||
|
||||
QDebug operator<<(QDebug dbg, const QDBusMessage &msg)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QDBusMessage(type=" << msg.type()
|
||||
<< ", service=" << msg.service();
|
||||
if (msg.type() == QDBusMessage::MethodCallMessage ||
|
||||
@ -799,7 +800,7 @@ QDebug operator<<(QDebug dbg, const QDBusMessage &msg)
|
||||
<< ", contents=(";
|
||||
debugVariantList(dbg, msg.arguments());
|
||||
dbg.nospace() << ") )";
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -601,8 +601,9 @@ QCursor::operator QVariant() const
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QCursor &c)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QCursor(Qt::CursorShape(" << c.shape() << "))";
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1601,8 +1601,9 @@ QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence)
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QKeySequence &p)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QKeySequence(" << p.toString() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1152,6 +1152,7 @@ QDebug operator<<(QDebug dbg, const QPalette &p)
|
||||
"BrightText", "ButtonText", "Base", "Window", "Shadow", "Highlight",
|
||||
"HighlightedText", "Link", "LinkVisited", "AlternateBase", "NoRole",
|
||||
"ToolTipBase","ToolTipText" };
|
||||
QDebugStateSaver saver(dbg);
|
||||
QDebug nospace = dbg.nospace();
|
||||
const uint mask = p.resolve();
|
||||
nospace << "QPalette(resolve=" << hex << showbase << mask << ',';
|
||||
@ -1171,7 +1172,7 @@ QDebug operator<<(QDebug dbg, const QPalette &p)
|
||||
}
|
||||
}
|
||||
nospace << ')' << noshowbase << dec;
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -88,14 +88,16 @@ struct QShortcutEntry
|
||||
/*! \internal
|
||||
QDebug operator<< for easy debug output of the shortcut entries.
|
||||
*/
|
||||
static QDebug &operator<<(QDebug &dbg, const QShortcutEntry *se) {
|
||||
static QDebug &operator<<(QDebug &dbg, const QShortcutEntry *se)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
if (!se)
|
||||
return dbg << "QShortcutEntry(0x0)";
|
||||
dbg.nospace()
|
||||
<< "QShortcutEntry(" << se->keyseq
|
||||
<< "), id(" << se->id << "), enabled(" << se->enabled << "), autorepeat(" << se->autorepeat
|
||||
<< "), owner(" << se->owner << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif // QT_NO_DEBUGSTREAM
|
||||
|
||||
|
@ -812,6 +812,7 @@ bool operator!=(const QSurfaceFormat& a, const QSurfaceFormat& b)
|
||||
QDebug operator<<(QDebug dbg, const QSurfaceFormat &f)
|
||||
{
|
||||
const QSurfaceFormatPrivate * const d = f.d;
|
||||
QDebugStateSaver saver(dbg);
|
||||
|
||||
dbg.nospace() << "QSurfaceFormat("
|
||||
<< "version " << d->major << '.' << d->minor
|
||||
@ -828,7 +829,7 @@ QDebug operator<<(QDebug dbg, const QSurfaceFormat &f)
|
||||
<< ", profile " << d->profile
|
||||
<< ')';
|
||||
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -781,10 +781,12 @@ void QWindowSystemInterface::handleEnterWhatsThisEvent()
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p) {
|
||||
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "TouchPoint(" << p.id << " @" << p.area << " normalized " << p.normalPosition
|
||||
<< " press " << p.pressure << " vel " << p.velocity << " state " << (int)p.state;
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -341,6 +341,7 @@ typedef QGenericMatrix<4, 3, float> QMatrix4x3;
|
||||
template <int N, int M, typename T>
|
||||
QDebug operator<<(QDebug dbg, const QGenericMatrix<N, M, T> &m)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QGenericMatrix<" << N << ", " << M
|
||||
<< ", " << QTypeInfo<T>::name()
|
||||
<< ">(" << endl << qSetFieldWidth(10);
|
||||
@ -350,7 +351,7 @@ QDebug operator<<(QDebug dbg, const QGenericMatrix<N, M, T> &m)
|
||||
dbg << endl;
|
||||
}
|
||||
dbg << qSetFieldWidth(0) << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -2010,6 +2010,7 @@ QMatrix4x4::operator QVariant() const
|
||||
|
||||
QDebug operator<<(QDebug dbg, const QMatrix4x4 &m)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
// Create a string that represents the matrix type.
|
||||
QByteArray bits;
|
||||
if (m.flagBits == QMatrix4x4::Identity) {
|
||||
@ -2039,7 +2040,7 @@ QDebug operator<<(QDebug dbg, const QMatrix4x4 &m)
|
||||
<< m(2, 0) << m(2, 1) << m(2, 2) << m(2, 3) << endl
|
||||
<< m(3, 0) << m(3, 1) << m(3, 2) << m(3, 3) << endl
|
||||
<< qSetFieldWidth(0) << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -950,10 +950,11 @@ QQuaternion::operator QVariant() const
|
||||
|
||||
QDebug operator<<(QDebug dbg, const QQuaternion &q)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QQuaternion(scalar:" << q.scalar()
|
||||
<< ", vector:(" << q.x() << ", "
|
||||
<< q.y() << ", " << q.z() << "))";
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -499,8 +499,9 @@ QVector2D::operator QVariant() const
|
||||
|
||||
QDebug operator<<(QDebug dbg, const QVector2D &vector)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QVector2D(" << vector.x() << ", " << vector.y() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -697,9 +697,10 @@ float QVector3D::lengthSquared() const
|
||||
|
||||
QDebug operator<<(QDebug dbg, const QVector3D &vector)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QVector3D("
|
||||
<< vector.x() << ", " << vector.y() << ", " << vector.z() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -573,10 +573,11 @@ QVector4D::operator QVariant() const
|
||||
|
||||
QDebug operator<<(QDebug dbg, const QVector4D &vector)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QVector4D("
|
||||
<< vector.x() << ", " << vector.y() << ", "
|
||||
<< vector.z() << ", " << vector.w() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1022,8 +1022,9 @@ QDebug operator<<(QDebug dbg, const QBrush &b)
|
||||
"TexturePattern" // 24
|
||||
};
|
||||
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2391,6 +2391,7 @@ void QColor::invalidate()
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QColor &c)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
if (!c.isValid())
|
||||
dbg.nospace() << "QColor(Invalid)";
|
||||
else if (c.spec() == QColor::Rgb)
|
||||
@ -2403,7 +2404,7 @@ QDebug operator<<(QDebug dbg, const QColor &c)
|
||||
else if (c.spec() == QColor::Hsl)
|
||||
dbg.nospace() << "QColor(AHSL " << c.alphaF() << ", " << c.hslHueF() << ", " << c.hslSaturationF() << ", " << c.lightnessF() << ')';
|
||||
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1130,6 +1130,7 @@ QDataStream &operator>>(QDataStream &s, QMatrix &m)
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QMatrix &m)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QMatrix("
|
||||
<< "11=" << m.m11()
|
||||
<< " 12=" << m.m12()
|
||||
@ -1138,7 +1139,7 @@ QDebug operator<<(QDebug dbg, const QMatrix &m)
|
||||
<< " dx=" << m.dx()
|
||||
<< " dy=" << m.dy()
|
||||
<< ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -942,6 +942,7 @@ QRect QPageLayout::paintRectPixels(int resolution) const
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QPageLayout &layout)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
if (layout.isValid()) {
|
||||
QString output = QStringLiteral("QPageLayout(%1, %2, l:%3 r:%4 t:%5 b:%6 %7)");
|
||||
QString units;
|
||||
@ -976,7 +977,7 @@ QDebug operator<<(QDebug dbg, const QPageLayout &layout)
|
||||
} else {
|
||||
dbg.nospace() << "QPageLayout()";
|
||||
}
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1854,6 +1854,7 @@ QSize QPageSize::sizePixels(PageSizeId pageSizeId, int resolution)
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QPageSize &pageSize)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
if (pageSize.isValid()) {
|
||||
QString output = QStringLiteral("QPageSize(\"%1\", \"%2\", %3x%4pt, %5)");
|
||||
output = output.arg(pageSize.name())
|
||||
@ -1865,7 +1866,7 @@ QDebug operator<<(QDebug dbg, const QPageSize &pageSize)
|
||||
} else {
|
||||
dbg.nospace() << "QPageSize()";
|
||||
}
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1026,12 +1026,13 @@ QDebug operator<<(QDebug dbg, const QPen &p)
|
||||
"CustomDashLine"
|
||||
};
|
||||
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QPen(" << p.width() << ',' << p.brush()
|
||||
<< ',' << PEN_STYLES[p.style()] << ',' << int(p.capStyle())
|
||||
<< ',' << int(p.joinStyle()) << ',' << p.dashPattern()
|
||||
<< ',' << p.dashOffset()
|
||||
<< ',' << p.miterLimit() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -461,11 +461,12 @@ QRect QPolygon::boundingRect() const
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QPolygon &a)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QPolygon(";
|
||||
for (int i = 0; i < a.count(); ++i)
|
||||
dbg.nospace() << a.at(i);
|
||||
dbg.nospace() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -802,11 +803,12 @@ QDataStream &operator>>(QDataStream &s, QPolygonF &a)
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QPolygonF &a)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QPolygonF(";
|
||||
for (int i = 0; i < a.count(); ++i)
|
||||
dbg.nospace() << a.at(i);
|
||||
dbg.nospace() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1091,6 +1091,7 @@ QDebug operator<<(QDebug dbg, const QTransform &m)
|
||||
"TxProject"
|
||||
};
|
||||
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QTransform(type=" << typeStr[m.type()] << ','
|
||||
<< " 11=" << m.m11()
|
||||
<< " 12=" << m.m12()
|
||||
@ -1103,7 +1104,7 @@ QDebug operator<<(QDebug dbg, const QTransform &m)
|
||||
<< " 33=" << m.m33()
|
||||
<< ')';
|
||||
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3458,14 +3458,16 @@ void QTextFormatCollection::setDefaultFont(const QFont &f)
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QTextLength &l)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QTextLength(QTextLength::Type(" << l.type() << "))";
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const QTextFormat &f)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QTextFormat(QTextFormat::FormatType(" << f.type() << "))";
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -119,9 +119,10 @@ QDataStream &operator>>(QDataStream &stream, QLayoutPolicy &policy)
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QLayoutPolicy &p)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QLayoutPolicy(horizontalPolicy = " << p.horizontalPolicy()
|
||||
<< ", verticalPolicy = " << p.verticalPolicy() << ')';
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1615,6 +1615,7 @@ QDebug operator<<(QDebug dbg, const QGLFormat &f)
|
||||
{
|
||||
const QGLFormatPrivate * const d = f.d;
|
||||
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QGLFormat("
|
||||
<< "options " << d->opts
|
||||
<< ", plane " << d->pln
|
||||
@ -1632,7 +1633,7 @@ QDebug operator<<(QDebug dbg, const QGLFormat &f)
|
||||
<< ", profile " << d->profile
|
||||
<< ')';
|
||||
|
||||
return dbg.space();
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user