V4 Debugger: Avoid special refs when looking up normal ones
authorUlf Hermann <ulf.hermann@theqtcompany.com>
Mon, 17 Aug 2015 14:54:36 +0000 (16:54 +0200)
committerUlf Hermann <ulf.hermann@theqtcompany.com>
Wed, 19 Aug 2015 11:28:25 +0000 (11:28 +0000)
The "values" of "special" refs are always JavaScript "undefined"s.
Thus, when trying to deduplicate an actual "undefined" we'd
accidentally hit the special refs. Avoid this by checking if a found
ref is special.

In an ideal world we'd get rid of the special refs altogether and
save QV4::FunctionObject in the values array, but that is not quite
trivial as long as the QV4::ExecutionEngine::stackTrace() doesn't
give us FunctionObjects.

Task-number: QTBUG-47788
Change-Id: Idf358c285f40930220fad2207c6ab5c9101573b2
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp

index 64ee5c3b96144e002f8423542c80b5d61e494e84..a44acdd37071cd9130ed5b2d7ec3e56245dd6353 100644 (file)
@@ -236,7 +236,7 @@ QV4DataCollector::Ref QV4DataCollector::addRef(QV4::Value value, bool deduplicat
     QV4::ScopedObject array(scope, values.value());
     if (deduplicate) {
         for (Ref i = 0; i < array->getLength(); ++i) {
-            if (array->getIndexed(i) == value.rawValue())
+            if (array->getIndexed(i) == value.rawValue() && !specialRefs.contains(i))
                 return i;
         }
     }