aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp4
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 23170ace92..5f8b7d31ca 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -487,8 +487,10 @@ Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Val
Q_ASSERT(!value.isObject());
switch (value.type()) {
case Value::Undefined_Type:
+ engine->throwTypeError(QLatin1String("Value is undefined and could not be converted to an object"));
+ return nullptr;
case Value::Null_Type:
- engine->throwTypeError();
+ engine->throwTypeError(QLatin1String("Value is null and could not be converted to an object"));
return nullptr;
case Value::Boolean_Type:
return engine->newBooleanObject(value.booleanValue());
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index acdee3a808..2e8f61ef10 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -8103,7 +8103,7 @@ void tst_qqmlecmascript::setPropertyOnInvalid()
QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("setPropertyOnNull.qml"));
- QString warning = component.url().toString() + ":4: TypeError: Type error";
+ QString warning = component.url().toString() + ":4: TypeError: Value is null and could not be converted to an object";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QObject *object = component.create();
QVERIFY(object);
@@ -8112,7 +8112,7 @@ void tst_qqmlecmascript::setPropertyOnInvalid()
{
QQmlComponent component(&engine, testFileUrl("setPropertyOnUndefined.qml"));
- QString warning = component.url().toString() + ":4: TypeError: Type error";
+ QString warning = component.url().toString() + ":4: TypeError: Value is undefined and could not be converted to an object";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QObject *object = component.create();
QVERIFY(object);