Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
5.12.5, 5.15.5
Description
In the attached example, binding to index causes a TypeError when removing the first item from the model. I'm assuming this is because it causes the binding to reevaluate while the model data is changing, but I don't believe this should cause issues. If this is expected behaviour, it should be documented.
Steps to reproduce:
- Run the attached example
- Click the button
main.qml
import QtQuick 2.0 import QtQuick.Controls 2.0 import Isle 1.0 ApplicationWindow { width: 640 height: 480 title: qsTr("Hello World") visible: true Flow { Repeater { id: pathRepeater model: PathModel { id: pathModel } delegate: Label { // Works fine // text: model.tilePos.toString() // TypeError: Cannot read property 'x' of undefined // Works if you comment out "index" in the last expression in parentheses. text: "(" + model.tilePos.x + ", " + model.tilePos.y + ")" + (index < pathRepeater.count - 1 ? " " : "") } } } Button { text: "Remove first path node" anchors.bottom: parent.bottom onClicked: pathModel.removeFirst() } }
Making "index" and "model" required properties doesn't make a difference:
required property int index required property var model
Making tilePos a required property is a workaround, however:
text: "(" + tilePos.x + ", " + tilePos.y + ")" + (index < pathRepeater.count - 1 ? " " : "") required property int index required property point tilePos
Attachments
Issue Links
- relates to
-
QTBUG-45500 QQuickListView keeps delegates around until next layout phase after model items have been removed
- Closed