mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 21:51:08 +00:00
gtkgridview: Fix crash on scroll to 0 sized tile
No longer crashes with my listview_clocks demo or in real scrolling in my application. "GtkGridView failed to scroll to given position. Ignoring..." warnings are printed when it would have crashed. Sometimes the scroll jumps incorrectly when it doesn't crash, but that's a separate bug but is probably related to whatever is causing this crash. Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5945, at least in terms of the immediate crash.
This commit is contained in:
parent
f13c8a3cb4
commit
a483fb2d96
@ -431,6 +431,11 @@ gtk_grid_view_get_position_from_allocation (GtkListBase *base,
|
||||
{
|
||||
guint rows_in_tile = tile->n_items / self->n_columns;
|
||||
guint row_height = (tile->area.height + yspacing) / rows_in_tile - yspacing;
|
||||
|
||||
/* tile has no computed area */
|
||||
if (row_height + yspacing == 0)
|
||||
return FALSE;
|
||||
|
||||
guint row_index = MIN (tile->area.height - 1, y - tile->area.y) / (row_height + yspacing);
|
||||
pos += self->n_columns * row_index;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user