Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.5.0 Beta2
-
None
-
Qt 6.5.0 beta2, Qt Creator 9.0.1, Linux Mint 20.2 Cinnamon
-
-
e5c2b236a (dev), 72e546bc7 (6.5)
Description
It seems that in QML the first time that an expression with nullish coalescing and/or optional chaining is evaluated, this evaluation fails.
Example:
Take the following QT example: https://doc.qt.io/qt-6/qtquick-models-stringlistmodel-example.html
If I change the delegate by adding a
property var test
and by modifying the text content as follows
Text { text: parent.test ?? parent.modelData }
the first three items in the list are displayed correctly with the value contained in modelData, while the last one is empty and in console I have the following error:
qrc:/qt/qml/stringlistmodel/view.qml:17:16: Unable to assign [undefined] to QString
Similarly, if I change the text this way
Text { text: parent.test?.prop ?? parent.modelData }
again the first three items in the list are displayed correctly with the value contained in modelData, while the last one is empty and in console I have the following error:
qrc:/qt/qml/stringlistmodel/view.qml:17: TypeError: Cannot read property 'prop' of undefined
I would expect that the error would be logged either for every delegate item (i.e. it is a programming error) or for none, but not just for one element, and the same applies for the displayed values.
The same changes work as expected with Qt 6.2.3 and 6.4.2