diff options
author | Jędrzej Nowacki <jedrzej.nowacki@nokia.com> | 2012-03-16 16:32:38 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-21 06:55:33 +0100 |
commit | 37b0a8e7e645b97df57aae44059b2aa35bc909c3 (patch) | |
tree | 6eabf3e58332cb9ca3c0863cdee9d7fa09ef4178 /src | |
parent | c236842241f9fcfff3274d8b1b7b1f365dc9227f (diff) |
Fix qDebug stream for an invalid QVariant.
This patch changes invalid QVariant qDebug stream value from
"QVariant(, QVariant::Invalid)" to "QVariant(Invalid)"
New tests were added.
Change-Id: Ia57d4fc2d775cc9fce28e03eba402c2173845b35
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 43d867f61c..cbef47566c 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2686,15 +2686,24 @@ bool QVariant::isNull() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QVariant &v) { - dbg.nospace() << "QVariant(" << QMetaType::typeName(v.userType()) << ", "; - handlerManager[v.d.type]->debugStream(dbg, v); + const uint typeId = v.d.type; + dbg.nospace() << "QVariant("; + if (typeId != QMetaType::UnknownType) { + dbg.nospace() << QMetaType::typeName(typeId) << ", "; + handlerManager[typeId]->debugStream(dbg, v); + } else { + dbg.nospace() << "Invalid"; + } dbg.nospace() << ')'; return dbg.space(); } QDebug operator<<(QDebug dbg, const QVariant::Type p) { - dbg.nospace() << "QVariant::" << QMetaType::typeName(p); + dbg.nospace() << "QVariant::" + << (int(p) != int(QMetaType::UnknownType) + ? QMetaType::typeName(p) + : "Invalid"); return dbg.space(); } #endif |