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/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 ++- 6 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/gui/math3d') 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 -- cgit v1.2.3