views/agenda: Only scroll when there are items

`gtk_list_view_scroll_to()` is documented to require that `pos` is
smaller than the number of items in the model. We were not checking
if the model was empty before calling this function, which could
lead to criticals.

Check if the listview model has any items before scrolling it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/860>
This commit is contained in:
Georges Basile Stavracas Neto
2026-10-02 18:19:13 -03:00
parent 6c2bc5be46
commit a1c3439535
+2 -1
View File
@@ -255,7 +255,8 @@ gcal_agenda_view_set_date (GcalView *view,
gcal_agenda_view_day_set_date (day, next_date);
}
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));