fix(CollectiblesView): Workaround for crash when hiding collectibles

In some rare cases hiding collectibles was causing segfault, related to
checking if all timestamps are available. Combination of 2 SFPMs with
the same source and Aggregator working on those models. Additionally
filters/sorters were depending on the Aggregator value. The minimal
crashing sample has been isolated to be investigated in a separate
ticket. In this commit aggregator's value is applied in a deferred way
via Qt.callLater, fixing the issue.

Closes: #15775
This commit is contained in:
Michał Cieślak 2024-08-07 10:55:54 +02:00 committed by Michał
parent 021756fcd6
commit 8f21c71f69
1 changed files with 11 additions and 4 deletions

View File

@ -72,7 +72,7 @@ ColumnLayout {
Component.onCompleted: { Component.onCompleted: {
settings.sync() settings.sync()
if (settings.currentSortValue === SortOrderComboBox.TokenOrderDateAdded && !d.hasAllTimestampsAggregator.value) { if (settings.currentSortValue === SortOrderComboBox.TokenOrderDateAdded && !d.hasAllTimestamps) {
cmbTokenOrder.currentIndex = cmbTokenOrder.indexOfValue(SortOrderComboBox.TokenOrderAlpha) // Change to a different default option cmbTokenOrder.currentIndex = cmbTokenOrder.indexOfValue(SortOrderComboBox.TokenOrderAlpha) // Change to a different default option
} else { } else {
cmbTokenOrder.currentIndex = cmbTokenOrder.indexOfValue(settings.currentSortValue) // Change to a different default option cmbTokenOrder.currentIndex = cmbTokenOrder.indexOfValue(settings.currentSortValue) // Change to a different default option
@ -213,12 +213,19 @@ ColumnLayout {
initialValue: true initialValue: true
roleName: "lastTxTimestamp" roleName: "lastTxTimestamp"
aggregateFunction: (aggr, value) => aggr && !!value aggregateFunction: (aggr, value) => aggr && value > 0
onValueChanged: { onValueChanged: {
d.setSortByDateIsDisabled(value) Qt.callLater(() => {
d.hasAllTimestamps = value
d.setSortByDateIsDisabled(value)
})
} }
Component.onCompleted: d.hasAllTimestamps = value
} }
property bool hasAllTimestamps
} }
component CustomSFPM: SortFilterProxyModel { component CustomSFPM: SortFilterProxyModel {
@ -353,7 +360,7 @@ ColumnLayout {
id: cmbTokenOrder id: cmbTokenOrder
hasCustomOrderDefined: root.controller.hasSettings hasCustomOrderDefined: root.controller.hasSettings
model: [ model: [
{ value: SortOrderComboBox.TokenOrderDateAdded, text: qsTr("Date added"), icon: "", sortRoleName: "lastTxTimestamp", isDisabled: !d.hasAllTimestampsAggregator.value }, // Custom SFPM role { value: SortOrderComboBox.TokenOrderDateAdded, text: qsTr("Date added"), icon: "", sortRoleName: "lastTxTimestamp", isDisabled: !d.hasAllTimestamps }, // Custom SFPM role
{ value: SortOrderComboBox.TokenOrderAlpha, text: qsTr("Collectible name"), icon: "", sortRoleName: "name" }, { value: SortOrderComboBox.TokenOrderAlpha, text: qsTr("Collectible name"), icon: "", sortRoleName: "name" },
{ value: SortOrderComboBox.TokenOrderGroupName, text: qsTr("Collection/community name"), icon: "", sortRoleName: "groupName" }, // Custom SFPM role communityName || collectionName { value: SortOrderComboBox.TokenOrderGroupName, text: qsTr("Collection/community name"), icon: "", sortRoleName: "groupName" }, // Custom SFPM role communityName || collectionName
{ value: SortOrderComboBox.TokenOrderCustom, text: qsTr("Custom order"), icon: "", sortRoleName: "" }, { value: SortOrderComboBox.TokenOrderCustom, text: qsTr("Custom order"), icon: "", sortRoleName: "" },