Skip to content

Ensure that we don't change n_items() without an items_changed signal#219

Merged
miek merged 1 commit intogreatscottgadgets:mainfrom
martinling:row-count-fix
Mar 5, 2025
Merged

Ensure that we don't change n_items() without an items_changed signal#219
miek merged 1 commit intogreatscottgadgets:mainfrom
martinling:row-count-fix

Conversation

@martinling
Copy link
Member

In the ListModel interface, we must always report a n_items() that is consistent with the history of items_changed signals we have emitted.

So keep a published row count separately from our internal counts, and update it just before emitting an items_changed signal. Fixes crashes in GTK where the view gets out of sync with the model.

Initially triggered by #150, but I think it's possible for the crash to occur independently of that.

In the ListModel interface, we must always report a n_items() that is
consistent with the history of `items_changed` signals we have emitted.

So keep a published row count separately from our internal counts, and
update it just before emitting an `items_changed` signal.

Fixes crashes in GTK where the view gets out of sync with the model.
@martinling martinling marked this pull request as ready for review February 25, 2025 17:18
@miek miek merged commit 4fd9846 into greatscottgadgets:main Mar 5, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants