diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 76fea1a3e0..723bb478ad 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -234,7 +234,7 @@ namespace QtPrivate { template inline QDebug printSequentialContainer(QDebug debug, const char *which, const SequentialContainer &c) { - const bool oldSetting = debug.autoInsertSpaces(); + const QDebugStateSaver saver(debug); debug.nospace() << which << '('; typename SequentialContainer::const_iterator it = c.begin(), end = c.end(); if (it != end) { @@ -246,22 +246,20 @@ inline QDebug printSequentialContainer(QDebug debug, const char *which, const Se ++it; } debug << ')'; - debug.setAutoInsertSpaces(oldSetting); - return debug.maybeSpace(); + return debug; } template inline QDebug printAssociativeContainer(QDebug debug, const char *which, const AssociativeContainer &c) { - const bool oldSetting = debug.autoInsertSpaces(); + const QDebugStateSaver saver(debug); debug.nospace() << which << "("; for (typename AssociativeContainer::const_iterator it = c.constBegin(); it != c.constEnd(); ++it) { debug << '(' << it.key() << ", " << it.value() << ')'; } debug << ')'; - debug.setAutoInsertSpaces(oldSetting); - return debug.maybeSpace(); + return debug; } } // namespace QtPrivate @@ -332,10 +330,9 @@ inline QDebug operator<<(QDebug debug, const QPair &pair) template inline QDebug operator<<(QDebug debug, const std::pair &pair) { - const bool oldSetting = debug.autoInsertSpaces(); + const QDebugStateSaver saver(debug); debug.nospace() << "std::pair(" << pair.first << ',' << pair.second << ')'; - debug.setAutoInsertSpaces(oldSetting); - return debug.maybeSpace(); + return debug; } template @@ -347,7 +344,7 @@ inline QDebug operator<<(QDebug debug, const QSet &set) template inline QDebug operator<<(QDebug debug, const QContiguousCache &cache) { - const bool oldSetting = debug.autoInsertSpaces(); + const QDebugStateSaver saver(debug); debug.nospace() << "QContiguousCache("; for (int i = cache.firstIndex(); i <= cache.lastIndex(); ++i) { debug << cache[i]; @@ -355,8 +352,7 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache &cache) debug << ", "; } debug << ')'; - debug.setAutoInsertSpaces(oldSetting); - return debug.maybeSpace(); + return debug; } template