diff options
author | Lars Knoll <lars.knoll@qt.io> | 2016-11-24 15:49:39 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2016-11-29 20:00:03 +0000 |
commit | a36d19546891a808cf71dbb084d6d63870d2b8ec (patch) | |
tree | 37d3ed91068950aeecfeb5d4ad79c030bbe4be87 /src/qml/jsruntime/qv4dateobject.cpp | |
parent | 6b641549536d199a0314049a34e61363bd4df7e0 (diff) |
Clean up some duplicated methods
Change-Id: Iad64dd2c330ca85a28f8f5c776b0ede623203558
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4dateobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4dateobject.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 4f3138a452..5af26f8f36 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -1319,14 +1319,17 @@ ReturnedValue DatePrototype::method_toISOString(CallContext *ctx) ReturnedValue DatePrototype::method_toJSON(CallContext *ctx) { Scope scope(ctx); - ScopedValue O(scope, RuntimeHelpers::toObject(scope.engine, ctx->thisObject())); + ScopedObject O(scope, ctx->thisObject().toObject(scope.engine)); + if (scope.hasException()) + return Encode::undefined(); + ScopedValue tv(scope, RuntimeHelpers::toPrimitive(O, NUMBER_HINT)); if (tv->isNumber() && !std::isfinite(tv->toNumber())) return Encode::null(); ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toISOString"))); - ScopedValue v(scope, O->objectValue()->get(s)); + ScopedValue v(scope, O->get(s)); FunctionObject *toIso = v->as<FunctionObject>(); if (!toIso) |