Qml Debugger: Properly handle JavaScript null

The QML engine might (in the future) actually send the right message
to indicate a JavaScript null, that is:

{ type: "object", value: null }

This piece of JSON is then transformed into a QVariantMap. The QVariant
that signifies the null is unfortunately different across various Qt
versions. We can, however, detect it.

Change-Id: I3db42bb35a936bc02c749ab3a136b1d297aefdfe
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Ulf Hermann
2017-03-20 11:51:18 +01:00
parent 8f94691ad6
commit f51d554bd1

View File

@@ -1696,10 +1696,16 @@ QmlV8ObjectData QmlEnginePrivate::extractData(const QVariant &data) const
if (dataMap.contains("value")) {
QVariant value = dataMap.value("value");
if (value.isNull())
// The QVariant representation of null has changed across various Qt versions
// 5.6, 5.7: QVariant::Invalid
// 5.8: isValid(), !isNull(), type() == 51; only typeName() is unique: "std::nullptr_t"
// 5.9: isValid(), isNull(); We can then use isNull()
if (!value.isValid() || value.isNull()
|| strcmp(value.typeName(), "std::nullptr_t") == 0) {
objectData.value = "null"; // Yes, null is an object.
else if (value.isValid())
} else if (value.isValid()) {
objectData.expectedProperties = value.toInt();
}
}
if (dataMap.contains("properties"))