From 868201155fd677dbc6d14346f5ea61e82ebce27b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 23 Jan 2015 16:19:11 +0100 Subject: 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 --- src/corelib/json/qjsonvalue.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/corelib/json/qjsonvalue.cpp') diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp index 4c5d9e3308..bc2bca2823 100644 --- a/src/corelib/json/qjsonvalue.cpp +++ b/src/corelib/json/qjsonvalue.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -709,12 +709,13 @@ QJsonValue QJsonValueRef::toValue() const #if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY) QDebug operator<<(QDebug dbg, const QJsonValue &o) { + QDebugStateSaver saver(dbg); switch (o.t) { case QJsonValue::Undefined: - dbg.nospace() << "QJsonValue(undefined)"; + dbg << "QJsonValue(undefined)"; break; case QJsonValue::Null: - dbg.nospace() << "QJsonValue(null)"; + dbg << "QJsonValue(null)"; break; case QJsonValue::Bool: dbg.nospace() << "QJsonValue(bool, " << o.toBool() << ")"; @@ -727,16 +728,16 @@ QDebug operator<<(QDebug dbg, const QJsonValue &o) break; case QJsonValue::Array: dbg.nospace() << "QJsonValue(array, "; - dbg.nospace() << o.toArray(); - dbg.nospace() << ")"; + dbg << o.toArray(); + dbg << ")"; break; case QJsonValue::Object: dbg.nospace() << "QJsonValue(object, "; - dbg.nospace() << o.toObject(); - dbg.nospace() << ")"; + dbg << o.toObject(); + dbg << ")"; break; } - return dbg.space(); + return dbg; } #endif -- cgit v1.2.3