forked from AuroraMiddleware/gtk
selectionfiltermodel: Fix an oversight
When the position is out of range, get_item needs to return NULL. Fixes: #4024
This commit is contained in:
parent
ee34e1acc5
commit
a526daf310
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user