views/agenda: Fix critical in first weekday changed

The `gcal_agenda_view_first_weekday_changed` uses the same
`gtk_list_view_scroll_to` method that expects the scroll position to be
smaller than the number of items in the list model.

When the list model contains no items, the method reports a critical
which crashes the Calendar whith `fatal-criticals` enabled.

This is the same fix that Georges made in the
`gcal_agenda_view_set_date` method. We now check the number of items
before trying to scroll the list view to position zero.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/861>
This commit is contained in:
mindonwarp
2026-10-03 12:58:02 +02:00
parent b09d79a9b1
commit 0a72c05311
+3 -1
View File
@@ -305,7 +305,9 @@ gcal_agenda_view_first_weekday_changed (GcalView *view)
{
GcalAgendaView *self = GCAL_AGENDA_VIEW (view);
gtk_list_view_scroll_to (self->list_view, 0, GTK_LIST_SCROLL_FOCUS, NULL);
if (g_list_model_get_n_items (G_LIST_MODEL (self->flatten_model)) > 0)
gtk_list_view_scroll_to (self->list_view, 0, GTK_LIST_SCROLL_FOCUS, NULL);
gcal_timeline_subscriber_range_changed (GCAL_TIMELINE_SUBSCRIBER (view));
}