aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4reflect.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-08 23:27:05 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-09 15:52:19 +0000
commitccd9bd94147dbacbaae3dba4c6fb9425877faaee (patch)
tree42b7ea45d896058ffc6e088c4096210ebacee3e3 /src/qml/jsruntime/qv4reflect.cpp
parentd1885b403196af17e931c24f3c98fc8afd03f005 (diff)
Small correctness fix in Reflect.ownKeys()
Change-Id: If4af20d25781c663f55cf9d6107a660f6540869d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4reflect.cpp')
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
index 766a0c4592..1b08d38eef 100644
--- a/src/qml/jsruntime/qv4reflect.cpp
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -42,6 +42,7 @@
#include "qv4runtimeapi_p.h"
#include "qv4objectproto_p.h"
#include "qv4propertykey_p.h"
+#include "qv4objectiterator_p.h"
using namespace QV4;
@@ -226,17 +227,19 @@ ReturnedValue Reflect::method_ownKeys(const FunctionObject *f, const Value *, co
if (!O)
return Encode::undefined();
- ScopedArrayObject keys(scope, ObjectPrototype::getOwnPropertyNames(scope.engine, O));
-
- Heap::InternalClass *ic = O->d()->internalClass;
- ScopedValue n(scope);
- for (uint i = 0; i < ic->size; ++i) {
- PropertyKey id = ic->nameMap.at(i);
- n = id.asStringOrSymbol();
- if (!n || !n->isSymbol())
- continue;
- keys->push_back(n);
+ ScopedArrayObject keys(scope, scope.engine->newArrayObject());
+
+ ObjectIterator it(scope, O, ObjectIterator::WithSymbols);
+ ScopedPropertyKey key(scope);
+ ScopedValue v(scope);
+ while (1) {
+ key = it.next();
+ if (!key->isValid())
+ break;
+ v = key->toStringOrSymbol(scope.engine);
+ keys->push_back(v);
}
+
return keys->asReturnedValue();
}