From 3fbf54df83105dd2ee5ada6af401dec4503462a4 Mon Sep 17 00:00:00 2001
From: Ulf Hermann <ulf.hermann@theqtcompany.com>
Date: Mon, 17 Aug 2015 17:30:13 +0200
Subject: [PATCH] Debugger: Properly handle JavaScript null

null is an object in JavaScript. This is slightly insane, but hiding
it in the debugger view doesn't help.

Change-Id: I69fe317f28a515785720104f92306f69a2e56266
Reviewed-by: hjk <hjk@theqtcompany.com>
---
 src/plugins/debugger/qml/qmlengine.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp
index f8dcc2372c..cea3191f7c 100644
--- a/src/plugins/debugger/qml/qmlengine.cpp
+++ b/src/plugins/debugger/qml/qmlengine.cpp
@@ -1664,8 +1664,8 @@ QmlV8ObjectData QmlEnginePrivate::extractData(const QVariant &data) const
             objectData.type = QByteArray("undefined");
             objectData.value = QVariant(_("undefined"));
 
-        } else if (type == _("null")) {
-            objectData.type = QByteArray("null");
+        } else if (type == _("null")) { // Deprecated. typeof(null) == "object" in JavaScript
+            objectData.type = QByteArray("object");
             objectData.value= QVariant(_("null"));
 
         } else if (type == _("boolean")) {
@@ -1683,9 +1683,12 @@ QmlV8ObjectData QmlEnginePrivate::extractData(const QVariant &data) const
 
         } else if (type == _("object")) {
             objectData.type = QByteArray("object");
-            objectData.value = dataMap.value(_("className"));
-            objectData.properties = dataMap.value(_("properties")).toList();
+            // ignore "className": it doesn't make any sense.
 
+            if (dataMap.contains(_("properties")))
+                objectData.properties = dataMap.value(_("properties")).toList();
+            else if (dataMap.value(_("value")).isNull())
+                objectData.value = QVariant(_("null")); // Yes, null is an object.
         } else if (type == _("function")) {
             objectData.type = QByteArray("function");
             objectData.value = dataMap.value(_(NAME));
-- 
GitLab