aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-11-19 00:31:04 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-19 07:57:45 +0100
commitcac9989643d54b15ea0b8e53889336b429e4504d (patch)
tree35211bbb4829385c2c91d4296b2a9d4e5929030b /tests
parentda31479ee237a40ed03bcaf1352f00d33d1f325c (diff)
Fix failing assertion when trying to assign to an id referenced QML object
References to id addressed QML objects are member expressions, which are unlike other member expressions by not being lvalues. Handle this correctly. Task-Number: QTBUG-34890 Change-Id: Ied6230edbc561128ad36bf0d1a1918185204deec Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/idAsLValue.qml7
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp11
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/idAsLValue.qml b/tests/auto/qml/qqmlecmascript/data/idAsLValue.qml
new file mode 100644
index 0000000000..1035f844b4
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/idAsLValue.qml
@@ -0,0 +1,7 @@
+import QtQml 2.0
+QtObject {
+ id: root
+ Component.onCompleted: {
+ root = "hello"
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 6af8863de7..6e1e606fb8 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -317,6 +317,7 @@ private slots:
void setPropertyOnInvalid();
void miscTypeTest();
void stackLimits();
+ void idsAsLValues();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -7466,6 +7467,16 @@ void tst_qqmlecmascript::stackLimits()
engine.evaluate(QStringLiteral("function foo() {foo();} try {foo()} catch(e) { }"));
}
+void tst_qqmlecmascript::idsAsLValues()
+{
+ QString err = QString(QLatin1String("%1:5 left-hand side of assignment operator is not an lvalue\n")).arg(testFileUrl("idAsLValue.qml").toString());
+ QQmlComponent component(&engine, testFileUrl("idAsLValue.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(!object);
+ QCOMPARE(component.errorString(), err);
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"