From 3203ac3f4e245427902bd912cb0c644c7e870657 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 30 Mar 2015 14:24:21 +0200 Subject: 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 --- src/dbus/qdbuserror.cpp | 3 ++- src/dbus/qdbusintegrator.cpp | 6 ++++-- src/dbus/qdbusmessage.cpp | 3 ++- src/gui/kernel/qcursor.cpp | 3 ++- src/gui/kernel/qkeysequence.cpp | 3 ++- src/gui/kernel/qpalette.cpp | 3 ++- src/gui/kernel/qshortcutmap.cpp | 6 ++++-- src/gui/kernel/qsurfaceformat.cpp | 3 ++- src/gui/kernel/qwindowsysteminterface.cpp | 6 ++++-- src/gui/math3d/qgenericmatrix.h | 3 ++- src/gui/math3d/qmatrix4x4.cpp | 3 ++- src/gui/math3d/qquaternion.cpp | 3 ++- src/gui/math3d/qvector2d.cpp | 3 ++- src/gui/math3d/qvector3d.cpp | 3 ++- src/gui/math3d/qvector4d.cpp | 3 ++- src/gui/painting/qbrush.cpp | 3 ++- src/gui/painting/qcolor.cpp | 3 ++- src/gui/painting/qmatrix.cpp | 3 ++- src/gui/painting/qpagelayout.cpp | 3 ++- src/gui/painting/qpagesize.cpp | 3 ++- src/gui/painting/qpen.cpp | 3 ++- src/gui/painting/qpolygon.cpp | 6 ++++-- src/gui/painting/qtransform.cpp | 3 ++- src/gui/text/qtextformat.cpp | 6 ++++-- src/gui/util/qlayoutpolicy.cpp | 3 ++- src/opengl/qgl.cpp | 3 ++- 26 files changed, 62 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp index 0cfb0aa7c2..2b13f90fac 100644 --- a/src/dbus/qdbuserror.cpp +++ b/src/dbus/qdbuserror.cpp @@ -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 diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 74d6a11dee..6edf08ebbe 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -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) diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp index 491e1273e7..b92e7f5cd7 100644 --- a/src/dbus/qdbusmessage.cpp +++ b/src/dbus/qdbusmessage.cpp @@ -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 diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 7e073370f2..6ed750eda1 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -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 diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index bdf401aa2d..23d5f06aa2 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -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 diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 58bcc2cc5b..cf17e1b5aa 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -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 diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 16d278b473..0ff5c36119 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -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 diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index d5f5b358b3..d078336d73 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -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 diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 73b1a84005..b17978cb7d 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -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 diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h index afce9d935e..89bc09f544 100644 --- a/src/gui/math3d/qgenericmatrix.h +++ b/src/gui/math3d/qgenericmatrix.h @@ -341,6 +341,7 @@ typedef QGenericMatrix<4, 3, float> QMatrix4x3; template QDebug operator<<(QDebug dbg, const QGenericMatrix &m) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QGenericMatrix<" << N << ", " << M << ", " << QTypeInfo::name() << ">(" << endl << qSetFieldWidth(10); @@ -350,7 +351,7 @@ QDebug operator<<(QDebug dbg, const QGenericMatrix &m) dbg << endl; } dbg << qSetFieldWidth(0) << ')'; - return dbg.space(); + return dbg; } #endif diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 09b41ac570..eb7c7f4b7a 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -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 diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index 90d90448e0..6914a0b45e 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -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 diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp index fe4c9f8cc2..2d8a1d3a0f 100644 --- a/src/gui/math3d/qvector2d.cpp +++ b/src/gui/math3d/qvector2d.cpp @@ -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 diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp index ced4ac9d73..19aa4facdb 100644 --- a/src/gui/math3d/qvector3d.cpp +++ b/src/gui/math3d/qvector3d.cpp @@ -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 diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp index 6afe9b8cad..494e6f97f0 100644 --- a/src/gui/math3d/qvector4d.cpp +++ b/src/gui/math3d/qvector4d.cpp @@ -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 diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 27f28f7193..5bf8387400 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -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 diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 945b150375..a6b44cde15 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -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 diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp index 679b5000cb..acedc6a7ba 100644 --- a/src/gui/painting/qmatrix.cpp +++ b/src/gui/painting/qmatrix.cpp @@ -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 diff --git a/src/gui/painting/qpagelayout.cpp b/src/gui/painting/qpagelayout.cpp index c1b23960ad..f443bbd5ac 100644 --- a/src/gui/painting/qpagelayout.cpp +++ b/src/gui/painting/qpagelayout.cpp @@ -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 diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp index fe445c0aec..c0aae603b7 100644 --- a/src/gui/painting/qpagesize.cpp +++ b/src/gui/painting/qpagesize.cpp @@ -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 diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index 4796d2c0ad..6263d18b01 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -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 diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp index 511af49787..efcc8875a5 100644 --- a/src/gui/painting/qpolygon.cpp +++ b/src/gui/painting/qpolygon.cpp @@ -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 diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 4c1aff92ae..31d7a2300b 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -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 diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index efd12b2b15..c60d0cc775 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -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 diff --git a/src/gui/util/qlayoutpolicy.cpp b/src/gui/util/qlayoutpolicy.cpp index f1900122ac..0a050184a6 100644 --- a/src/gui/util/qlayoutpolicy.cpp +++ b/src/gui/util/qlayoutpolicy.cpp @@ -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 diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index ca133f8830..5aec058532 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -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 -- cgit v1.2.3