diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index b316c2866e..00177b659e 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -174,6 +174,7 @@ template inline QDebug operator<<(QDebug debug, const QList &list) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << '('; for (typename QList::size_type i = 0; i < list.count(); ++i) { if (i) @@ -181,7 +182,8 @@ inline QDebug operator<<(QDebug debug, const QList &list) debug << list.at(i); } debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } #if defined(FORCE_UREF) @@ -192,7 +194,9 @@ template inline QDebug operator<<(QDebug debug, const QVector &vec) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QVector"; + debug.setAutoInsertSpaces(oldSetting); return operator<<(debug, vec.toList()); } @@ -204,13 +208,15 @@ template inline QDebug operator<<(QDebug debug, const QMap &map) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QMap("; for (typename QMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it) { debug << '(' << it.key() << ", " << it.value() << ')'; } debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } #if defined(FORCE_UREF) @@ -221,12 +227,14 @@ template inline QDebug operator<<(QDebug debug, const QHash &hash) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QHash("; for (typename QHash::const_iterator it = hash.constBegin(); it != hash.constEnd(); ++it) debug << '(' << it.key() << ", " << it.value() << ')'; debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } #if defined(FORCE_UREF) @@ -237,14 +245,18 @@ template inline QDebug operator<<(QDebug debug, const QPair &pair) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QPair(" << pair.first << ',' << pair.second << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } template inline QDebug operator<<(QDebug debug, const QSet &set) { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QSet"; + debug.setAutoInsertSpaces(oldSetting); return operator<<(debug, set.toList()); } @@ -256,6 +268,7 @@ template inline QDebug operator<<(QDebug debug, const QContiguousCache &cache) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QContiguousCache("; for (int i = cache.firstIndex(); i <= cache.lastIndex(); ++i) { debug << cache[i]; @@ -263,7 +276,8 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache &cache) debug << ", "; } debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } #if defined(FORCE_UREF) @@ -274,6 +288,7 @@ template inline QDebug operator<<(QDebug debug, const QFlags &flags) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QFlags("; bool needSeparator = false; for (uint i = 0; i < sizeof(T) * 8; ++i) { @@ -286,7 +301,8 @@ inline QDebug operator<<(QDebug debug, const QFlags &flags) } } debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } QT_END_NAMESPACE