summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
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/tools
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/tools')
-rw-r--r--src/corelib/tools/qbitarray.cpp11
-rw-r--r--src/corelib/tools/qdatetime.cpp9
-rw-r--r--src/corelib/tools/qeasingcurve.cpp1
-rw-r--r--src/corelib/tools/qlocale.cpp10
-rw-r--r--src/corelib/tools/qmargins.cpp6
-rw-r--r--src/corelib/tools/qregexp.cpp3
-rw-r--r--src/corelib/tools/qregularexpression.cpp11
-rw-r--r--src/corelib/tools/qtimezone.cpp3
-rw-r--r--src/corelib/tools/qversionnumber.cpp3
9 files changed, 36 insertions, 21 deletions
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp
index 5c391d7e4f..ddccd8cd02 100644
--- a/src/corelib/tools/qbitarray.cpp
+++ b/src/corelib/tools/qbitarray.cpp
@@ -772,18 +772,19 @@ QDataStream &operator>>(QDataStream &in, QBitArray &ba)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QBitArray &array)
{
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QBitArray(";
for (int i = 0; i < array.size();) {
if (array.testBit(i))
- dbg.nospace() << '1';
+ dbg << '1';
else
- dbg.nospace() << '0';
+ dbg << '0';
i += 1;
if (!(i % 4) && (i < array.size()))
- dbg.nospace() << ' ';
+ dbg << ' ';
}
- dbg.nospace() << ')';
- return dbg.space();
+ dbg << ')';
+ return dbg;
}
#endif
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index b95ccc0874..656638834f 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -5006,18 +5006,21 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime)
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING)
QDebug operator<<(QDebug dbg, const QDate &date)
{
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QDate(" << date.toString(Qt::ISODate) << ')';
- return dbg.space();
+ return dbg;
}
QDebug operator<<(QDebug dbg, const QTime &time)
{
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QTime(" << time.toString(QStringLiteral("HH:mm:ss.zzz")) << ')';
- return dbg.space();
+ return dbg;
}
QDebug operator<<(QDebug dbg, const QDateTime &date)
{
+ QDebugStateSaver saver(dbg);
QString spec;
switch (date.d->m_spec) {
case Qt::UTC:
@@ -5037,7 +5040,7 @@ QDebug operator<<(QDebug dbg, const QDateTime &date)
}
QString output = date.toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz t")) + spec;
dbg.nospace() << "QDateTime(" << output << ')';
- return dbg.space();
+ return dbg;
}
#endif
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index e6fb531d7d..7d63f95d1b 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -1417,6 +1417,7 @@ qreal QEasingCurve::valueForProgress(qreal progress) const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QEasingCurve &item)
{
+ QDebugStateSaver saver(debug);
debug << "type:" << item.d_ptr->type
<< "func:" << item.d_ptr->func;
if (item.d_ptr->config) {
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 78334563dd..f589777e65 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -3583,10 +3583,12 @@ QString QLocale::nativeCountryName() const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QLocale &l)
{
- dbg.nospace() << "QLocale(" << qPrintable(QLocale::languageToString(l.language()))
- << ", " << qPrintable(QLocale::scriptToString(l.script()))
- << ", " << qPrintable(QLocale::countryToString(l.country())) << ')';
- return dbg.space();
+ QDebugStateSaver saver(dbg);
+ dbg.nospace().noquote()
+ << "QLocale(" << QLocale::languageToString(l.language())
+ << ", " << QLocale::scriptToString(l.script())
+ << ", " << QLocale::countryToString(l.country()) << ')';
+ return dbg;
}
#endif
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp
index 265e44bfcf..b91e57ce39 100644
--- a/src/corelib/tools/qmargins.cpp
+++ b/src/corelib/tools/qmargins.cpp
@@ -432,9 +432,10 @@ QDataStream &operator>>(QDataStream &s, QMargins &m)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QMargins &m) {
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QMargins(" << m.left() << ", "
<< m.top() << ", " << m.right() << ", " << m.bottom() << ')';
- return dbg.space();
+ return dbg;
}
#endif
@@ -764,9 +765,10 @@ QDataStream &operator>>(QDataStream &s, QMarginsF &m)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QMarginsF &m) {
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QMarginsF(" << m.left() << ", "
<< m.top() << ", " << m.right() << ", " << m.bottom() << ')';
- return dbg.space();
+ return dbg;
}
#endif
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 71d897082b..e0ee8b12db 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -4577,9 +4577,10 @@ QDataStream &operator>>(QDataStream &in, QRegExp &regExp)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QRegExp &r)
{
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QRegExp(patternSyntax=" << r.patternSyntax()
<< ", pattern='"<< r.pattern() << "')";
- return dbg.space();
+ return dbg;
}
#endif
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 228ee5b842..2d469414ee 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -2444,8 +2444,9 @@ QDataStream &operator>>(QDataStream &in, QRegularExpression &re)
*/
QDebug operator<<(QDebug debug, const QRegularExpression &re)
{
+ QDebugStateSaver saver(debug);
debug.nospace() << "QRegularExpression(" << re.pattern() << ", " << re.patternOptions() << ")";
- return debug.space();
+ return debug;
}
/*!
@@ -2458,6 +2459,7 @@ QDebug operator<<(QDebug debug, const QRegularExpression &re)
*/
QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOptions)
{
+ QDebugStateSaver saver(debug);
QByteArray flags;
if (patternOptions == QRegularExpression::NoPatternOption) {
@@ -2487,7 +2489,7 @@ QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOption
debug.nospace() << "QRegularExpression::PatternOptions(" << flags << ")";
- return debug.space();
+ return debug;
}
/*!
\relates QRegularExpressionMatch
@@ -2499,11 +2501,12 @@ QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOption
*/
QDebug operator<<(QDebug debug, const QRegularExpressionMatch &match)
{
+ QDebugStateSaver saver(debug);
debug.nospace() << "QRegularExpressionMatch(";
if (!match.isValid()) {
debug << "Invalid)";
- return debug.space();
+ return debug;
}
debug << "Valid";
@@ -2528,7 +2531,7 @@ QDebug operator<<(QDebug debug, const QRegularExpressionMatch &match)
debug << ")";
- return debug.space();
+ return debug;
}
#endif
diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp
index 30c4c60167..f11a574c6f 100644
--- a/src/corelib/tools/qtimezone.cpp
+++ b/src/corelib/tools/qtimezone.cpp
@@ -980,9 +980,10 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QTimeZone &tz)
{
+ QDebugStateSaver saver(dbg);
//TODO Include backend and data version details?
dbg.nospace() << "QTimeZone(" << QString::fromUtf8(tz.id()) << ')';
- return dbg.space();
+ return dbg;
}
#endif
diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp
index 7817cabe33..40f6004514 100644
--- a/src/corelib/tools/qversionnumber.cpp
+++ b/src/corelib/tools/qversionnumber.cpp
@@ -458,8 +458,9 @@ QDataStream& operator>>(QDataStream &in, QVersionNumber &version)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QVersionNumber &version)
{
+ QDebugStateSaver saver(debug);
debug.noquote() << version.toString();
- return debug.quote();
+ return debug;
}
#endif