aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4jsonobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-12-02 12:54:53 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-12-20 10:07:47 +0100
commit3f7bab3a92ff5c1d623c633d8a925ff1a9ab5bde (patch)
tree8eec76cb67c772b7dc58d86c5d68a6bb76e96fe6 /src/qml/jsruntime/qv4jsonobject.cpp
parenta8efa705ac21ec020474b9dcc8ab454ddedad037 (diff)
Fix JSON stringification to work with heap objects
Change-Id: Ifbd7332602d67daa945da5ebbca797d0045aff68 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index 6b38c79d55..26cfe10f21 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -641,11 +641,13 @@ struct Stringify
{
ExecutionContext *ctx;
FunctionObject *replacerFunction;
- QVector<String *> propertyList;
+ // ### GC
+ QVector<Heap::String *> propertyList;
QString gap;
QString indent;
- QStack<Object *> stack;
+ // ### GC
+ QStack<Heap::Object *> stack;
Stringify(ExecutionContext *ctx) : ctx(ctx), replacerFunction(0) {}
@@ -776,7 +778,7 @@ QString Stringify::makeMember(const QString &key, ValueRef v)
QString Stringify::JO(Object *o)
{
- if (stack.contains(o)) {
+ if (stack.contains(o->d())) {
ctx->engine()->throwTypeError();
return QString();
}
@@ -784,7 +786,7 @@ QString Stringify::JO(Object *o)
Scope scope(ctx);
QString result;
- stack.push(o);
+ stack.push(o->d());
QString stepback = indent;
indent += gap;
@@ -833,7 +835,7 @@ QString Stringify::JO(Object *o)
QString Stringify::JA(ArrayObject *a)
{
- if (stack.contains(a)) {
+ if (stack.contains(a->d())) {
ctx->engine()->throwTypeError();
return QString();
}
@@ -841,7 +843,7 @@ QString Stringify::JA(ArrayObject *a)
Scope scope(a->engine());
QString result;
- stack.push(a);
+ stack.push(a->d());
QString stepback = indent;
indent += gap;
@@ -924,8 +926,8 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx)
v = RuntimeHelpers::toString(scope.engine, v);
if (v->isString()) {
String *s = v->stringValue();
- if (!stringify.propertyList.contains(s))
- stringify.propertyList.append(s);
+ if (!stringify.propertyList.contains(s->d()))
+ stringify.propertyList.append(s->d());
}
}
}