Clear HList/GridView checked on model change

Clear the checked items and prevent potential segfaults
This commit is contained in:
miruka 2020-09-24 03:35:34 -04:00
parent 58613446f0
commit d9118ef24e
2 changed files with 12 additions and 2 deletions

View File

@ -41,6 +41,10 @@ GridView {
checkedChanged()
}
function uncheckAll() {
checked = {}
}
function toggleCheck(...indices) {
const checkedIndices = []
@ -121,7 +125,10 @@ GridView {
}
onSelectedCountChanged: if (! selectedCount) lastCheckedDelegateIndex = 0
onModelChanged: currentIndex = defaultCurrentIndex
onModelChanged: {
currentIndex = defaultCurrentIndex
uncheckAll()
}
HKineticScrollingDisabler {
id: mouseArea

View File

@ -140,7 +140,10 @@ ListView {
}
onSelectedCountChanged: if (! selectedCount) lastCheckedDelegateIndex = 0
onModelChanged: currentIndex = defaultCurrentIndex
onModelChanged: {
currentIndex = defaultCurrentIndex
uncheckAll()
}
HKineticScrollingDisabler {
width: enabled ? parent.width : 0