summaryrefslogtreecommitdiffstats
path: root/src/corelib/json
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2015-01-23 16:19:11 +0100
committerKai Koehne <kai.koehne@theqtcompany.com>2015-02-09 11:30:02 +0000
commit868201155fd677dbc6d14346f5ea61e82ebce27b (patch)
tree75d02a144c205d659e5851f95f306e3a12b0ff5e /src/corelib/json
parent6389160f04322449c34bd1ecfe53983e3b588943 (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/json')
-rw-r--r--src/corelib/json/qjsonarray.cpp3
-rw-r--r--src/corelib/json/qjsondocument.cpp3
-rw-r--r--src/corelib/json/qjsonobject.cpp3
-rw-r--r--src/corelib/json/qjsonvalue.cpp17
4 files changed, 15 insertions, 11 deletions
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index acbd7dda8f..72674b8c40 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -1154,6 +1154,7 @@ void QJsonArray::compact()
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
QDebug operator<<(QDebug dbg, const QJsonArray &a)
{
+ QDebugStateSaver saver(dbg);
if (!a.a) {
dbg << "QJsonArray()";
return dbg;
@@ -1163,7 +1164,7 @@ QDebug operator<<(QDebug dbg, const QJsonArray &a)
dbg.nospace() << "QJsonArray("
<< json.constData() // print as utf-8 string without extra quotation marks
<< ")";
- return dbg.space();
+ return dbg;
}
#endif
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index 6e64df42ad..fe8bfdf0b5 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -561,6 +561,7 @@ bool QJsonDocument::isNull() const
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
QDebug operator<<(QDebug dbg, const QJsonDocument &o)
{
+ QDebugStateSaver saver(dbg);
if (!o.d) {
dbg << "QJsonDocument()";
return dbg;
@@ -573,7 +574,7 @@ QDebug operator<<(QDebug dbg, const QJsonDocument &o)
dbg.nospace() << "QJsonDocument("
<< json.constData() // print as utf-8 string without extra quotation marks
<< ")";
- return dbg.space();
+ return dbg;
}
#endif
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index df604e4433..3210f05507 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -1111,6 +1111,7 @@ void QJsonObject::setValueAt(int i, const QJsonValue &val)
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
QDebug operator<<(QDebug dbg, const QJsonObject &o)
{
+ QDebugStateSaver saver(dbg);
if (!o.o) {
dbg << "QJsonObject()";
return dbg;
@@ -1120,7 +1121,7 @@ QDebug operator<<(QDebug dbg, const QJsonObject &o)
dbg.nospace() << "QJsonObject("
<< json.constData() // print as utf-8 string without extra quotation marks
<< ")";
- return dbg.space();
+ return dbg;
}
#endif
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