diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-01-23 16:19:11 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-02-09 11:30:02 +0000 |
commit | 868201155fd677dbc6d14346f5ea61e82ebce27b (patch) | |
tree | 75d02a144c205d659e5851f95f306e3a12b0ff5e /src/corelib/kernel | |
parent | 6389160f04322449c34bd1ecfe53983e3b588943 (diff) |
QtCore: Use QDebugStateSaver in (almost) all QDebug operator<<
Unify the behavior of the different operator<< by always using
QDebugStateSaver (appending an optional space at exit), and making
sure that the space(), nospace() setting isn't 'leaked'.
Change-Id: I38e4f82fa6f7419d8b5edfc4dc37495af497e8ac
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcoreapplication_win.cpp | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qppsattribute.cpp | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qtimerinfo_unix.cpp | 4 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 12 |
4 files changed, 14 insertions, 8 deletions
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 424ee3fdea..dfb358202d 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -1041,8 +1041,9 @@ QString decodeMSG(const MSG& msg) QDebug operator<<(QDebug dbg, const MSG &msg) { + QDebugStateSaver saver(dbg); dbg << decodeMSG(msg); - return dbg.nospace(); + return dbg; } #endif diff --git a/src/corelib/kernel/qppsattribute.cpp b/src/corelib/kernel/qppsattribute.cpp index 09d8d1bb0c..f4c067e35a 100644 --- a/src/corelib/kernel/qppsattribute.cpp +++ b/src/corelib/kernel/qppsattribute.cpp @@ -260,7 +260,8 @@ QVariant QPpsAttribute::toVariant() const QDebug operator<<(QDebug dbg, const QPpsAttribute &attribute) { - dbg << "QPpsAttribute("; + QDebugStateSaver saver(dbg); + dbg.nospace() << "QPpsAttribute("; switch (attribute.type()) { case QPpsAttribute::Number: diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp index 43674f2c9c..f4a42acb59 100644 --- a/src/corelib/kernel/qtimerinfo_unix.cpp +++ b/src/corelib/kernel/qtimerinfo_unix.cpp @@ -207,11 +207,13 @@ static timespec roundToMillisecond(timespec val) #ifdef QTIMERINFO_DEBUG QDebug operator<<(QDebug s, timeval tv) { + QDebugStateSaver saver(s); s.nospace() << tv.tv_sec << "." << qSetFieldWidth(6) << qSetPadChar(QChar(48)) << tv.tv_usec << reset; - return s.space(); + return s; } QDebug operator<<(QDebug s, Qt::TimerType t) { + QDebugStateSaver saver(s); s << (t == Qt::PreciseTimer ? "P" : t == Qt::CoarseTimer ? "C" : "VC"); return s; diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index df1b4ed872..9e61813e20 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3424,10 +3424,11 @@ bool QVariant::isNull() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QVariant &v) { + QDebugStateSaver saver(dbg); const uint typeId = v.d.type; dbg.nospace() << "QVariant("; if (typeId != QMetaType::UnknownType) { - dbg.nospace() << QMetaType::typeName(typeId) << ", "; + dbg << QMetaType::typeName(typeId) << ", "; bool userStream = false; bool canConvertToString = false; if (typeId >= QMetaType::User) { @@ -3439,19 +3440,20 @@ QDebug operator<<(QDebug dbg, const QVariant &v) else if (!userStream) handlerManager[typeId]->debugStream(dbg, v); } else { - dbg.nospace() << "Invalid"; + dbg << "Invalid"; } - dbg.nospace() << ')'; - return dbg.space(); + dbg << ')'; + return dbg; } QDebug operator<<(QDebug dbg, const QVariant::Type p) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QVariant::" << (int(p) != int(QMetaType::UnknownType) ? QMetaType::typeName(p) : "Invalid"); - return dbg.space(); + return dbg; } #endif |