aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@crimson.no>2017-05-16 19:08:28 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2017-05-19 08:42:53 +0000
commit6a02fb09af8dce6ca533e816d2223e070b30f294 (patch)
tree42d75815199efb0c32837db0faa7c6fb0e0e154c /tests
parentb078939cb86c7fd82335f4d4a815b6f62eb7b26f (diff)
QQmlIRBuilder: Only query type name cache for type names
The behavior here was always incorrect: type names must start with an uppercase letter, so querying the type name cache with a lowercase string is wrong. However, this was turned into a larger problem by making more extensive use of QQmlTypeNameCache in e74a1d0b342f2c95dc3a543c8c9ec07fd52d8fe0, as it contained a lot of new types (including composite types, which previously were only in the cache if they were singletons). Task-number: QTBUG-60547 Change-Id: I40be2d535e99d3e1af250d995d7149ecbe2965d7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml11
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml8
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp11
4 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml b/tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml
new file mode 100644
index 0000000000..5f022f605a
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.0
+import "components"
+
+QtObject {
+ id: root
+ property int counter
+ function increment() {
+ counter++
+ return counter
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml b/tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml
new file mode 100644
index 0000000000..3c5e65a340
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml
@@ -0,0 +1,4 @@
+import QtQuick 2.0
+
+QtObject {}
+
diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml b/tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml
new file mode 100644
index 0000000000..b09366e9df
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml
@@ -0,0 +1,8 @@
+import QtQml 2.0
+
+TestObject {
+ Component.onCompleted: {
+ increment()
+ }
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 72179d243f..7b9a43dc38 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -337,6 +337,7 @@ private slots:
void instanceof();
void freeze_empty_object();
void singleBlockLoops();
+ void qtbug_60547();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -8250,6 +8251,16 @@ void tst_qqmlecmascript::singleBlockLoops()
QVERIFY(!component.isError());
}
+// 'counter' was incorrectly resolved as a type rather than a variable.
+// This fix ensures it looks up the right thing.
+void tst_qqmlecmascript::qtbug_60547()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug60547/main.qml"));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
+ QCOMPARE(object->property("counter"), QVariant(int(1)));
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"