mirror of https://github.com/KDE/kasts.git
Fix app-crashing binding loop in FeedListPage
The binding loop occured whenever the vertical scrollbar appears or disappears. The GUI then gets stuck between solutions: one with a certain amount of columns and another with one column less or more. It then keeps alternating between these two until the app freezes the machine and eventually crashes. The fix is to calculate the number of columns based on the total width of the Page itself, rather than the width of the content. By subtracting enough space for the scrollbar, the cards on the page will now rescale smoothly and properly.
This commit is contained in:
parent
6c3615f65a
commit
e81b62839a
|
@ -94,11 +94,17 @@ Kirigami.ScrollablePage {
|
|||
|
||||
property int minimumCardSize: 150
|
||||
property int cardMargin: Kirigami.Units.largeSpacing
|
||||
// In order to account for the scrollbar popping up and creating a
|
||||
// binding loop, we calculate the number of columns and card width based
|
||||
// on the total width of the page itself rather than the width left for
|
||||
// the GridView, and then subtract some space
|
||||
property int availableWidth: subscriptionPage.width - !Kirigami.Settings.isMobile * Kirigami.Units.gridUnit * 1.3
|
||||
// TODO: get proper width for scrollbar rather than hardcoding it
|
||||
|
||||
property int columns: Math.floor(width / (minimumCardSize + 2 * cardMargin))
|
||||
property int columns: Math.max(1, Math.floor(availableWidth / (minimumCardSize + 2 * cardMargin)))
|
||||
|
||||
cellWidth: width / columns
|
||||
cellHeight: width / columns
|
||||
cellWidth: availableWidth / columns
|
||||
cellHeight: availableWidth / columns
|
||||
|
||||
model: FeedsModel {
|
||||
id: feedsModel
|
||||
|
@ -107,7 +113,7 @@ Kirigami.ScrollablePage {
|
|||
Component {
|
||||
id: feedListDelegate
|
||||
FeedListDelegate {
|
||||
cardSize: feedList.width / feedList.columns - 2 * feedList.cardMargin
|
||||
cardSize: feedList.availableWidth / feedList.columns - 2 * feedList.cardMargin
|
||||
cardMargin: feedList.cardMargin
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue