From 9fb449793dfe0a645682fb35441fe0831c8a1e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= Date: Thu, 25 Jan 2024 17:18:05 +0000 Subject: [PATCH] listitemmanager: Fix section change handler mistake The statement is not doing what it was meant to do. gtk_list_item_manager_get_nth (self, position, &offset) returns the tile for a given position, and if the tile maps to more than 1 item, the offset indicates how far into that tile the given position is. So position - offset would give us the position of this tile. It doesn't make sense to subtract it from n_items. Instead, we should be adding the offset to compensate for having landed too early in the list, such that we successfully reach position + n_items. --- gtk/gtklistitemmanager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtklistitemmanager.c b/gtk/gtklistitemmanager.c index 9a2f178704..82c6444cff 100644 --- a/gtk/gtklistitemmanager.c +++ b/gtk/gtklistitemmanager.c @@ -1625,7 +1625,7 @@ gtk_list_item_manager_model_sections_changed_cb (GListModel *model, gtk_list_item_change_clear_header (&change, &header->widget); gtk_list_tile_set_type (header, GTK_LIST_TILE_UNMATCHED_HEADER); - n_items -= MIN (n_items, position - offset); + n_items += offset; while (n_items > 0) { switch (tile->type)