Keep global state of debug stream (QImage, QPixmap, and QIcon)

Make sure that the stream's formatting settings are preserved.

Change-Id: Ib13b5e0b36b2ef801da2d2d5c240d28dc1b04653
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Kai Koehne 2014-07-22 08:41:17 +02:00
parent b5b4eb742c
commit 7aae6219d5
3 changed files with 30 additions and 24 deletions

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of the QtGui module of the Qt Toolkit. ** This file is part of the QtGui module of the Qt Toolkit.
@ -1321,18 +1321,20 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon)
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QIcon &i) QDebug operator<<(QDebug dbg, const QIcon &i)
{ {
QDebug nospace = dbg.nospace(); QDebugStateSaver saver(dbg);
nospace << "QIcon("; dbg.resetFormat();
dbg.nospace();
dbg << "QIcon(";
if (i.isNull()) { if (i.isNull()) {
nospace << "null"; dbg << "null";
} else { } else {
if (!i.name().isEmpty()) if (!i.name().isEmpty())
nospace << i.name() << ','; dbg << i.name() << ',';
nospace << "availableSizes[normal,Off]=" << i.availableSizes() dbg << "availableSizes[normal,Off]=" << i.availableSizes()
<< ",cacheKey=" << showbase << hex << i.cacheKey() << dec << noshowbase; << ",cacheKey=" << showbase << hex << i.cacheKey() << dec << noshowbase;
} }
nospace << ')'; dbg << ')';
return dbg.space(); return dbg;
} }
#endif #endif

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of the QtGui module of the Qt Toolkit. ** This file is part of the QtGui module of the Qt Toolkit.
@ -4550,19 +4550,21 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QImage &i) QDebug operator<<(QDebug dbg, const QImage &i)
{ {
QDebug nospace = dbg.nospace(); QDebugStateSaver saver(dbg);
nospace << "QImage("; dbg.resetFormat();
dbg.nospace();
dbg << "QImage(";
if (i.isNull()) { if (i.isNull()) {
nospace << "null"; dbg << "null";
} else { } else {
nospace << i.size() << ",format=" << i.format() << ",depth=" << i.depth(); dbg << i.size() << ",format=" << i.format() << ",depth=" << i.depth();
if (i.colorCount()) if (i.colorCount())
nospace << ",colorCount=" << i.colorCount(); dbg << ",colorCount=" << i.colorCount();
nospace << ",devicePixelRatio=" << i.devicePixelRatio() dbg << ",devicePixelRatio=" << i.devicePixelRatio()
<< ",bytesPerLine=" << i.bytesPerLine() << ",byteCount=" << i.byteCount(); << ",bytesPerLine=" << i.bytesPerLine() << ",byteCount=" << i.byteCount();
} }
nospace << ')'; dbg << ')';
return dbg.space(); return dbg;
} }
#endif #endif

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of the QtGui module of the Qt Toolkit. ** This file is part of the QtGui module of the Qt Toolkit.
@ -1724,17 +1724,19 @@ QPlatformPixmap* QPixmap::handle() const
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QPixmap &r) QDebug operator<<(QDebug dbg, const QPixmap &r)
{ {
QDebug nospace = dbg.nospace(); QDebugStateSaver saver(dbg);
nospace << "QPixmap("; dbg.resetFormat();
dbg.nospace();
dbg << "QPixmap(";
if (r.isNull()) { if (r.isNull()) {
nospace << "null"; dbg << "null";
} else { } else {
nospace << r.size() << ",depth=" << r.depth() dbg << r.size() << ",depth=" << r.depth()
<< ",devicePixelRatio=" << r.devicePixelRatio() << ",devicePixelRatio=" << r.devicePixelRatio()
<< ",cacheKey=" << showbase << hex << r.cacheKey() << dec << noshowbase; << ",cacheKey=" << showbase << hex << r.cacheKey() << dec << noshowbase;
} }
nospace << ')'; dbg << ')';
return dbg.space(); return dbg;
} }
#endif #endif