summaryrefslogtreecommitdiff
path: root/gtk/gtkgridview.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-06-20 12:11:59 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-06-20 12:11:59 -0400
commit2842030e59692e7e943c6db246485711e02e3883 (patch)
treec2d4243c426009d65f8449d9f5fc3ffafdf20024 /gtk/gtkgridview.c
parent7c2d21892fca112cbb4c1744460adff5f3661571 (diff)
downloadgtk+-2842030e59692e7e943c6db246485711e02e3883.tar.gz
gridview: Don't assert on a condition that can happen
We are currently not robust against model changes or widget invalidations, so we can actually end up in situations where we run out of items here. Handle the failure a bit more gracefully, by returning NULL. This is good enough to make scrolling work okish most of the time. We still need a proper fix to handle other situations.
Diffstat (limited to 'gtk/gtkgridview.c')
-rw-r--r--gtk/gtkgridview.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index b9c2c9a87c..5b2a381c69 100644
--- a/gtk/gtkgridview.c
+++ b/gtk/gtkgridview.c
@@ -270,7 +270,17 @@ gtk_grid_view_get_cell_at_y (GtkGridView *self,
if (pos % self->n_columns)
{
skip = self->n_columns - pos % self->n_columns;
- g_assert (n_items > skip);
+ if (n_items <= skip)
+ {
+ g_warning ("ran out of items");
+ if (position)
+ *position = 0;
+ if (offset)
+ *offset = 0;
+ if (size)
+ *size = 0;
+ return NULL;
+ }
n_items -= skip;
pos += skip;
}