aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp1
-rw-r--r--src/qml/qml/qqmlpropertycachecreator_p.h10
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasPropertyToIC.qml11
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp19
4 files changed, 39 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 5b44ead713..278977fb9c 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -1038,6 +1038,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) const
property.setWritable(data->isWritable());
property.setResettable(data->isResettable());
property.setBindable(data->isBindable());
+ property.setAlias(data->isAlias());
}
for (int ii = 0; ii < methods.count(); ++ii) {
diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h
index c8d516b367..09d8ace425 100644
--- a/src/qml/qml/qqmlpropertycachecreator_p.h
+++ b/src/qml/qml/qqmlpropertycachecreator_p.h
@@ -945,10 +945,16 @@ inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataFor
}
const auto referencedType = typeRef->type();
- if (referencedType.isValid())
+ if (referencedType.isValid()) {
*type = referencedType.typeId();
- else
+ if (!type->isValid() && referencedType.isInlineComponentType()) {
+ int objectId = referencedType.inlineComponentId();
+ *type = objectContainer->typeIdsForComponent(objectId).id;
+ Q_ASSERT(type->isValid());
+ }
+ } else {
*type = typeRef->compilationUnit()->typeIds.id;
+ }
*version = typeRef->version();
diff --git a/tests/auto/qml/qqmlecmascript/data/aliasPropertyToIC.qml b/tests/auto/qml/qqmlecmascript/data/aliasPropertyToIC.qml
new file mode 100644
index 0000000000..17116bb091
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/aliasPropertyToIC.qml
@@ -0,0 +1,11 @@
+import QtQml
+
+
+QtObject {
+ id: root
+
+ component Test : QtObject {}
+
+ property alias myalias: other
+ property var direct: Test { id: other }
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 547ccf4635..c68fc1019f 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -119,6 +119,7 @@ private slots:
void outerBindingOverridesInnerBinding();
void aliasPropertyAndBinding();
void aliasPropertyReset();
+ void aliasPropertyToIC();
void nonExistentAttachedObject();
void scope();
void importScope();
@@ -1935,6 +1936,24 @@ void tst_qqmlecmascript::aliasPropertyReset()
QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
}
+void tst_qqmlecmascript::aliasPropertyToIC()
+{
+ QQmlEngine engine;
+ std::unique_ptr<QObject> root;
+
+ // test that a manual write (of undefined) to a resettable aliased property succeeds
+ QQmlComponent c(&engine, testFileUrl("aliasPropertyToIC.qml"));
+ root.reset(c.create());
+ QVERIFY(root);
+ auto mo = root->metaObject();
+ int aliasIndex = mo->indexOfProperty("myalias");
+ auto prop = mo->property(aliasIndex);
+ QVERIFY(prop.isAlias());
+ auto fromAlias = prop.read(root.get()).value<QObject *>();
+ auto direct = root->property("direct").value<QObject *>();
+ QCOMPARE(fromAlias, direct);
+}
+
void tst_qqmlecmascript::componentCreation_data()
{
QTest::addColumn<QString>("method");