Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.0.0, 5.4.0
-
None
Description
Running the code below results in "TypeError: Cannot read property 'color' of null", because apparently the Binding tries to evaluate the value property even though the "when" statement evaluates to false.
To fix this, one could replace the "when" statement with the alternative "value" statement commented out below, but the current behavior seems wrong.
import QtQuick 2.0 Rectangle { id: root width: 300 height: 400 Binding { target: root property: "color" value: loader.item.color // value: loader.item ? loader.item.color : "white" when: Qt.isQtObject(loader.item) } Loader { id: loader anchors.centerIn: parent } MouseArea { anchors.fill: parent onClicked: loader.sourceComponent = rect } Component { id: rect Rectangle { width: 100 height: 100 color: "blue" border.color: "yellow" border.width: 5 } } }
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-22005 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
183782,6 | Evaluate QML Bindings expressions only when "when" is true | 5.15 | qt/qtdeclarative | Status: ABANDONED | -1 | 0 |