Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.6.0 Alpha
-
None
-
1e3924d8f585dd9099eb74ffbc17950c693d14da
Description
Run the following example and click one of the items => crash. The test case looks silly, but ListView really shouldn't crash that easily...
import QtQuick 2.2 import QtQml.Models 2.1 import QtQuick.Window 2.1 Window { id: window width: 360 height: 360 visible: true ListView { anchors.fill: parent anchors.margins: 20 spacing: 20 model: ObjectModel { MouseArea { width: 160; height: 160 Rectangle { anchors.fill: parent; color: "tan" } onClicked: destroy() } MouseArea { width: 160; height: 160 Rectangle { anchors.fill: parent; color: "thistle" } onClicked: destroy() } MouseArea { width: 160; height: 160 Rectangle { anchors.fill: parent; color: "tomato" } onClicked: destroy() } } } }
A more realistic use case is in Qt Quick Controls 2, namely TabBar and SwipeView. Both use ListView + ObjectModel internally, and offer an API to add/insert/move/remove items dynamically. This means that items may get destroyed while the view and model are still alive.