Fix exception type when trying to assign to read-only QObject properties
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 13 Jun 2013 06:24:25 +0000 (08:24 +0200)
committerLars Knoll <lars.knoll@digia.com>
Thu, 13 Jun 2013 06:54:32 +0000 (08:54 +0200)
[[Put]] throws a type error, and so should the put operation on a QObject

Change-Id: I8fad91f3969c1889381d67d8d0ff751a91f8239e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/v4/qv4qobjectwrapper.cpp
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

index f127a83..6aa9ece 100644 (file)
@@ -481,7 +481,7 @@ bool QObjectWrapper::setQmlProperty(ExecutionContext *ctx, QQmlContextData *qmlC
     if (!result->isWritable() && !result->isQList()) {
         QString error = QLatin1String("Cannot assign to read-only property \"") +
                         name->toQString() + QLatin1Char('\"');
-        ctx->throwError(error);
+        ctx->throwTypeError(error);
     }
 
     QQmlBinding *newBinding = 0;
index cdf46c4..d77c775 100644 (file)
@@ -1750,7 +1750,7 @@ void tst_qqmlecmascript::scriptErrors()
     QString warning4 = url + ":13: ReferenceError: a is not defined";
     QString warning5 = url + ":11: ReferenceError: a is not defined";
     QString warning6 = url + ":10:21: Unable to assign [undefined] to int";
-    QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\"";
+    QString warning7 = url + ":15: TypeError: Cannot assign to read-only property \"trueProperty\"";
     QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\"";
 
     QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
@@ -3619,7 +3619,7 @@ void tst_qqmlecmascript::singletonType_data()
             << testFileUrl("singletontype/qobjectSingletonTypeWriting.qml")
             << QString()
             << (QStringList() <<
-                    QString(testFileUrl("singletontype/qobjectSingletonTypeWriting.qml").toString() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
+                    QString(testFileUrl("singletontype/qobjectSingletonTypeWriting.qml").toString() + QLatin1String(":15: TypeError: Cannot assign to read-only property \"qobjectTestProperty\"")))
             << (QStringList() << "readOnlyProperty" << "writableProperty" << "writableFinalProperty")
             << (QVariantList() << 20 << 50 << 10)
             << (QStringList() << "firstProperty" << "secondProperty")