diff options
author | David Faure <david.faure@kdab.com> | 2014-02-07 16:12:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-13 17:59:50 +0100 |
commit | 91c9cae720004ad6bb0c7b3b7e6f64a9e6a6fcf3 (patch) | |
tree | 86f62e70350997d022af7f62d2aa89cff731c4c2 /src/corelib/tools | |
parent | 73d761ffe5ed9364e20e3766afe89213a089ec28 (diff) |
QDebugStateSaver: call maybeSpace() in destructor.
tst_qdebug didn't test adding something else after the MyLine object,
so I didn't realize that a space was missing there. All debug operators
should end with maybeSpace(), but with the settings of the caller, so this
requires restoring the settings before calling it. To make it convenient
for all << operators, the destructor of QDebugStateSaver takes care of that.
Change-Id: I18ab78d99d7ee3be951082b5b5d34718ee60e21d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qline.cpp | 14 | ||||
-rw-r--r-- | src/corelib/tools/qpoint.cpp | 13 | ||||
-rw-r--r-- | src/corelib/tools/qrect.cpp | 12 | ||||
-rw-r--r-- | src/corelib/tools/qsize.cpp | 12 |
4 files changed, 32 insertions, 19 deletions
diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index 990e6bef09..61c7899ef4 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -259,10 +259,11 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug d, const QLine &p) +QDebug operator<<(QDebug dbg, const QLine &p) { - d << "QLine(" << p.p1() << ',' << p.p2() << ')'; - return d; + QDebugStateSaver saver(dbg); + dbg.nospace() << "QLine(" << p.p1() << ',' << p.p2() << ')'; + return dbg; } #endif @@ -819,10 +820,11 @@ qreal QLineF::angle(const QLineF &l) const #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug d, const QLineF &p) +QDebug operator<<(QDebug dbg, const QLineF &p) { - d << "QLineF(" << p.p1() << ',' << p.p2() << ')'; - return d; + QDebugStateSaver saver(dbg); + dbg.nospace() << "QLineF(" << p.p1() << ',' << p.p2() << ')'; + return dbg; } #endif diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index 565b1223fe..f154e4c612 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -451,15 +451,18 @@ QDataStream &operator>>(QDataStream &s, QPoint &p) */ #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QPoint &p) { +QDebug operator<<(QDebug dbg, const QPoint &p) +{ + QDebugStateSaver saver(dbg); dbg.nospace() << "QPoint(" << p.x() << ',' << p.y() << ')'; - return dbg.space(); + return dbg; } -QDebug operator<<(QDebug d, const QPointF &p) +QDebug operator<<(QDebug dbg, const QPointF &p) { - d.nospace() << "QPointF(" << p.x() << ", " << p.y() << ')'; - return d.space(); + QDebugStateSaver saver(dbg); + dbg.nospace() << "QPointF(" << p.x() << ',' << p.y() << ')'; + return dbg; } #endif diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 33e8dd23fc..1b3a28839c 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -1285,10 +1285,12 @@ QDataStream &operator>>(QDataStream &s, QRect &r) #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QRect &r) { +QDebug operator<<(QDebug dbg, const QRect &r) +{ + QDebugStateSaver saver(dbg); dbg.nospace() << "QRect(" << r.x() << ',' << r.y() << ' ' << r.width() << 'x' << r.height() << ')'; - return dbg.space(); + return dbg; } #endif @@ -2491,10 +2493,12 @@ QDataStream &operator>>(QDataStream &s, QRectF &r) #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QRectF &r) { +QDebug operator<<(QDebug dbg, const QRectF &r) +{ + QDebugStateSaver saver(dbg); dbg.nospace() << "QRectF(" << r.x() << ',' << r.y() << ' ' << r.width() << 'x' << r.height() << ')'; - return dbg.space(); + return dbg; } #endif diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index b53eced298..da447157ff 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -445,9 +445,11 @@ QDataStream &operator>>(QDataStream &s, QSize &sz) #endif // QT_NO_DATASTREAM #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QSize &s) { +QDebug operator<<(QDebug dbg, const QSize &s) +{ + QDebugStateSaver saver(dbg); dbg.nospace() << "QSize(" << s.width() << ", " << s.height() << ')'; - return dbg.space(); + return dbg; } #endif @@ -870,9 +872,11 @@ QDataStream &operator>>(QDataStream &s, QSizeF &sz) #endif // QT_NO_DATASTREAM #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QSizeF &s) { +QDebug operator<<(QDebug dbg, const QSizeF &s) +{ + QDebugStateSaver saver(dbg); dbg.nospace() << "QSizeF(" << s.width() << ", " << s.height() << ')'; - return dbg.space(); + return dbg; } #endif |