Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5.2
-
None
Description
In the following minimal reproducible example Component::createObject is called on a component of some type that has a list property, and that list property is initialized with an empty JavaScript array value. The fact that it is empty is not important, because component would attempt to interpret array value as a whole as a QtObject, causing it to be casted as null.
In fact, passing some actual QObject without array brackets results in a list property having that one single object in it.
import QtQml QtObject { objectName: "root" property Component testComponent: QtObject { property list<QtObject> bug } Component.onCompleted: { let obj = testComponent.createObject(this, { bug: [], }); print(obj, obj.bug.length, obj.bug); // Prints: QObject_QML_1 1 [null] obj = testComponent.createObject(this, { bug: this, }); print(obj, obj.bug.length, obj.bug); // Prints: QObject_QML_1 1 [QObject_QML_0("root")] } }