diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-12-07 16:19:30 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-12-09 10:18:42 +0000 |
commit | 893f2ade8573af56f761a1361dfe1e1f03154bdd (patch) | |
tree | 2663e25259aa835a6554c255e5dd9a872d67ffeb | |
parent | 5ac2b391333d0b3047b64dd840a8109274b0fe88 (diff) |
Fix debug operator for QRegion.
Use QDebugStateSaver, drop the multiline format, check for null, empty and
output rectangular regions as:
QRegion(0,0 252x188)
and complicated regions as:
QRegion(size=4, bounds=(0,0 278x262) - [(0,0 278x13), (0,13 13x188), (265,13 13x188), (0,201 278x61)])
Change-Id: I82b8f58af08f7128e6cf2c2c8b06c4684fc6a9c8
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
-rw-r--r-- | src/gui/painting/qregion.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index e6b777a30e..5e648eabf5 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -41,7 +41,7 @@ #include "qimage.h" #include "qbitmap.h" -#include <qdebug.h> +#include <private/qdebug_p.h> QT_BEGIN_NAMESPACE @@ -422,11 +422,32 @@ QDataStream &operator>>(QDataStream &s, QRegion &r) #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug s, const QRegion &r) { - QVector<QRect> rects = r.rects(); - s.nospace() << "QRegion(size=" << rects.size() << "), " - << "bounds = " << r.boundingRect() << '\n'; - for (int i=0; i<rects.size(); ++i) - s << "- " << i << rects.at(i) << '\n'; + QDebugStateSaver saver(s); + s.nospace(); + s << "QRegion("; + if (r.isNull()) { + s << "null"; + } else if (r.isEmpty()) { + s << "empty"; + } else { + const QVector<QRect> rects = r.rects(); + const int count = rects.size(); + if (count > 1) + s << "size=" << count << ", bounds=("; + QtDebugUtils::formatQRect(s, r.boundingRect()); + if (count > 1) { + s << ") - ["; + for (int i = 0; i < count; ++i) { + if (i) + s << ", "; + s << '('; + QtDebugUtils::formatQRect(s, rects.at(i)); + s << ')'; + } + s << ']'; + } + } + s << ')'; return s; } #endif |