aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4jsonobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-01-10 22:04:54 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2015-01-12 14:52:50 +0100
commit447844aa25754db7e868469de4537af4331709ac (patch)
tree80245a0d948e87c8cfd7a35eb5fdc93a65105ccd /src/qml/jsruntime/qv4jsonobject.cpp
parent56211be8a0429fb3e3fa268c7698e1df079aa04e (diff)
Get rid of Value::engine()
This method is not guaranteed to return an engine. We're safer checking for the value being an object first and then getting the engine from there. Change-Id: I5c95e675337e545f2421613bd31c42d1e58d6f9a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index f320630181..0de2aa7e3b 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -984,9 +984,11 @@ QJsonValue JsonObject::toJsonValue(const ValueRef value,
return QJsonValue(QJsonValue::Null);
else if (value->isUndefined())
return QJsonValue(QJsonValue::Undefined);
+ else if (value->isString())
+ return QJsonValue(value->toQString());
- Q_ASSERT(value->engine());
- Scope scope(value->engine());
+ Q_ASSERT(value->isObject());
+ Scope scope(value->asObject()->engine());
ScopedArrayObject a(scope, value);
if (a)
return toJsonArray(a, visitedObjects);