aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlpropertycache
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-09-05 16:41:11 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-09-13 15:10:49 +0200
commit28eb0caec23e0c315056cb035535b8806ccb0f37 (patch)
treeef17b4cf984a04c94804cae29e5b546f37060f87 /tests/auto/qml/qqmlpropertycache
parent122d0367fd96526b3573a3188286153c846680ca (diff)
Force creation of metaobjects for top level objects and components
We want those to be different types, even if they don't add any properties, signals etc. Otherwise you can cross-assign objects of components defined in different files. Fully-dynamic types, such as QQmlPropertyMap are still an exception to this. We need to use the original meta object so that you can still dynamically add properties to any derived types. Therefore, all types derived from QQmlPropertyMap are in fact just aliases of each other. Also, types which aren't addressable from the outside don't get their own meta object. Types are addressable if they live in files and the file name starts with an uppercase character. Otherwise there is no way to refer to the component from anywhere else in QML. Fixes: QTBUG-76021 Change-Id: I96a01fdad13e50e4705520fec46f2b3373e0c365 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlpropertycache')
-rw-r--r--tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml5
-rw-r--r--tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml5
-rw-r--r--tests/auto/qml/qqmlpropertycache/data/noDuckType.qml7
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp11
4 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml b/tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml
new file mode 100644
index 0000000000..9559bc0b5f
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml
@@ -0,0 +1,5 @@
+import QtQml 2.0
+
+QtObject {
+ readonly property bool fakeProperty: false
+}
diff --git a/tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml b/tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml
new file mode 100644
index 0000000000..ed4ad04fef
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml
@@ -0,0 +1,5 @@
+import QtQml 2.0
+
+QtObject {
+ objectName: "special"
+}
diff --git a/tests/auto/qml/qqmlpropertycache/data/noDuckType.qml b/tests/auto/qml/qqmlpropertycache/data/noDuckType.qml
new file mode 100644
index 0000000000..5e1ea233b9
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertycache/data/noDuckType.qml
@@ -0,0 +1,7 @@
+import QtQml 2.9
+
+QtObject {
+ property SpecialObject1 obj1: SpecialObject1 {}
+ property SpecialObject2 obj2: SpecialObject2 {}
+ property string result: (obj1 instanceof SpecialObject2) ? "bad" : "good"
+}
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
index 9a1e4667dd..c9e92cd3c9 100644
--- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -54,6 +54,7 @@ private slots:
void metaObjectSize_data();
void metaObjectSize();
void metaObjectChecksum();
+ void metaObjectsForRootElements();
private:
QQmlEngine engine;
@@ -543,4 +544,14 @@ void tst_qqmlpropertycache::metaObjectChecksum()
}
}
+void tst_qqmlpropertycache::metaObjectsForRootElements()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("noDuckType.qml"));
+ QVERIFY(c.isReady());
+ QScopedPointer<QObject> obj(c.create());
+ QVERIFY(!obj.isNull());
+ QCOMPARE(obj->property("result").toString(), QString::fromLatin1("good"));
+}
+
QTEST_MAIN(tst_qqmlpropertycache)