GListModel interface not correctly implemented by GtkSelectionFilterModel
GtkSelectionFilterModel item getter always returns an item, whatever the position.
Steps to reproduce
#include <gtk/gtk.h>
int
main (int argc, char *argv[])
{
GtkStringList *stringlist;
GtkStringObject *stringobject;
GtkMultiSelection *selection;
GtkSelectionFilterModel *selection_filter;
stringlist = gtk_string_list_new (NULL);
gtk_string_list_append (stringlist, "first item");
selection = gtk_multi_selection_new(G_LIST_MODEL (stringlist));
selection_filter = gtk_selection_filter_model_new (GTK_SELECTION_MODEL (selection));
g_print ("Items: %d\n", g_list_model_get_n_items(G_LIST_MODEL (selection_filter))); /* Items: 0 */
stringobject = g_list_model_get_item(G_LIST_MODEL (selection_filter), 87);
if (stringobject != NULL)
g_print ("String: %s\n", gtk_string_object_get_string(stringobject)); /* String: first item */
}
Current behavior
In this example, an empty GtkSelectionFilterModel
instance returns an item when querying an arbitrary position.
Expected outcome
According to the GListModel
documentation, g_list_model_get_item
must return NULL
if the position is greater than the number of items in the list.
Version information
GTK 4.2.1.