selectionfiltermodel: Fix an oversight

When the position is out of range, get_item needs
to return NULL.

Fixes: #4024
This commit is contained in:
Matthias Clasen 2021-06-11 15:37:16 -04:00
parent ee34e1acc5
commit a526daf310

View File

@ -64,10 +64,10 @@ gtk_selection_filter_model_get_n_items (GListModel *list)
{
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (list);
if (self->selection)
return gtk_bitset_get_size (self->selection);
if (!self->selection)
return 0;
return 0;
return gtk_bitset_get_size (self->selection);
}
static gpointer
@ -76,6 +76,12 @@ gtk_selection_filter_model_get_item (GListModel *list,
{
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (list);
if (!self->selection)
return NULL;
if (position >= gtk_bitset_get_size (self->selection))
return NULL;
position = gtk_bitset_get_nth (self->selection, position);
return g_list_model_get_item (G_LIST_MODEL (self->model), position);