diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-16 15:27:16 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-18 13:14:52 +0200 |
commit | 4241a5583623be758df3884c133acff2e11cd33f (patch) | |
tree | cfc16898aca7238b3bf985e893db3fb7c7a85158 | |
parent | 382709e14daeeb5132d6e39043b1140f251fc49b (diff) |
Fix handling of empty Values
Make things consistent between 32 and 64 bit again
Adjust test results after the changes
Almost all uses of Value::empty() will get removed
in the future, but for now this gets all our tests
to pass again.
Change-Id: I44784a43432e78febbdfe78115c9be2a3e3ece76
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 6fc0eaae67..2bd201e2a1 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -617,6 +617,7 @@ Returned<String> *__qmljs_convert_to_string(ExecutionContext *ctx, const ValueRe { switch (value->type()) { case Value::Undefined_Type: + case Value::Empty_Type: return ctx->engine->id_undefined->asReturned<String>(); case Value::Null_Type: return ctx->engine->id_null->asReturned<String>(); @@ -969,7 +970,7 @@ ReturnedValue __qmljs_call_property(ExecutionContext *context, String *name, Cal Scope scope(context); Scoped<Object> baseObject(scope, callData->thisObject); if (!baseObject) { - if (callData->thisObject.isNullOrUndefined()) { + if (callData->thisObject.isNullOrUndefined() || callData->thisObject.isEmpty()) { QString message = QStringLiteral("Cannot call method '%1' of %2").arg(name->toQString()).arg(callData->thisObject.toQStringNoThrow()); context->throwTypeError(message); } diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index ac47f48baf..f97aa66669 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -108,6 +108,7 @@ QString Value::toQStringNoThrow() const { switch (type()) { case Value::Undefined_Type: + case Value::Empty_Type: return QStringLiteral("undefined"); case Value::Null_Type: return QStringLiteral("null"); @@ -156,6 +157,7 @@ QString Value::toQString() const { switch (type()) { case Value::Undefined_Type: + case Value::Empty_Type: return QStringLiteral("undefined"); case Value::Null_Type: return QStringLiteral("null"); diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 086ffbae64..892e708aa4 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -6640,7 +6640,7 @@ void tst_qqmlecmascript::qtbug_22843() QQmlComponent component(&engine, testFileUrl(fileName)); QString url = component.url().toString(); QString warning1 = url.left(url.length()-3) + QLatin1String("js:4:16: Expected token `;'"); - QString warning2 = url + QLatin1String(":5: TypeError: Property 'func' of object NaN is not a function"); + QString warning2 = url + QLatin1String(":5: TypeError: Cannot call method 'func' of undefined"); qRegisterMetaType<QList<QQmlError> >("QList<QQmlError>"); QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QQmlError>))); |