diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 274a86591b..a9e7549685 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3163,9 +3163,11 @@ QDebug operator<<(QDebug dbg, const QVariant &v) if (typeId != QMetaType::UnknownType) { dbg.nospace() << QMetaType::typeName(typeId) << ", "; bool userStream = false; - if (typeId >= QMetaType::User) + bool canConvertToString = false; + if (typeId >= QMetaType::User) { userStream = QMetaType::debugStream(dbg, constData(v.d), typeId); - bool canConvertToString = v.canConvert(); + canConvertToString = v.canConvert(); + } if (!userStream && canConvertToString) dbg << v.toString(); else if (!userStream)