aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4jsonobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <[email protected]>2013-09-18 16:36:02 +0200
committerThe Qt Project <[email protected]>2013-09-22 01:06:20 +0200
commitdf5edd28bc4258b89d9d5ffdddf837f339a17aad (patch)
tree2a5939d5e3c49928aadf43337832d3ef5a58df08 /src/qml/jsruntime/qv4jsonobject.cpp
parent700ba1bcb39e082049c96fafdfaccfe5d83cd77e (diff)
convert Managed::put() API to be GC safe
Change-Id: I09198ce372fa545372db389fac26828d21ad5731 Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index 6dec2d1ec6..e3e159233b 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -716,7 +716,8 @@ QString Stringify::Str(const QString &key, Value value)
if (replacerFunction) {
Scoped<Object> holder(scope, ctx->engine->newObject());
- holder->put(ctx, QString(), value);
+ ScopedValue v(scope, value);
+ holder->put(ctx, QString(), v);
ScopedCallData callData(scope, 2);
callData->args[0] = Value::fromString(ctx, key);
callData->args[1] = value;
@@ -985,8 +986,12 @@ QV4::ReturnedValue JsonObject::fromJsonObject(ExecutionEngine *engine, const QJs
{
Scope scope(engine);
Scoped<Object> o(scope, engine->newObject());
- for (QJsonObject::const_iterator it = object.begin(); it != object.end(); ++it)
- o->put(engine->newString(it.key()), Value::fromReturnedValue(fromJsonValue(engine, it.value())));
+ ScopedString s(scope);
+ ScopedValue v(scope);
+ for (QJsonObject::const_iterator it = object.begin(); it != object.end(); ++it) {
+ v = Value::fromReturnedValue(fromJsonValue(engine, it.value()));
+ o->put((s = engine->newString(it.key())), v);
+ }
return o.asReturnedValue();
}