From 8f21c71f696092930a07b33c383894812a92731b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Wed, 7 Aug 2024 10:55:54 +0200 Subject: [PATCH] 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 --- .../AppLayouts/Wallet/views/CollectiblesView.qml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml b/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml index 56ff9f2992..4ef0c3838e 100644 --- a/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml +++ b/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml @@ -72,7 +72,7 @@ ColumnLayout { Component.onCompleted: { 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 } else { cmbTokenOrder.currentIndex = cmbTokenOrder.indexOfValue(settings.currentSortValue) // Change to a different default option @@ -213,12 +213,19 @@ ColumnLayout { initialValue: true roleName: "lastTxTimestamp" - aggregateFunction: (aggr, value) => aggr && !!value + aggregateFunction: (aggr, value) => aggr && value > 0 onValueChanged: { - d.setSortByDateIsDisabled(value) + Qt.callLater(() => { + d.hasAllTimestamps = value + d.setSortByDateIsDisabled(value) + }) } + + Component.onCompleted: d.hasAllTimestamps = value } + + property bool hasAllTimestamps } component CustomSFPM: SortFilterProxyModel { @@ -353,7 +360,7 @@ ColumnLayout { id: cmbTokenOrder hasCustomOrderDefined: root.controller.hasSettings 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.TokenOrderGroupName, text: qsTr("Collection/community name"), icon: "", sortRoleName: "groupName" }, // Custom SFPM role communityName || collectionName { value: SortOrderComboBox.TokenOrderCustom, text: qsTr("Custom order"), icon: "", sortRoleName: "" },