diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c index 43e2956c1a67e071a6664ab1ec4a5e1f0fa4dfd6..42b6ff28f15a532ec9829a42a98f729a7ce3fee1 100644 --- a/gtk/gtkcolumnview.c +++ b/gtk/gtkcolumnview.c @@ -2188,7 +2188,8 @@ gtk_column_view_set_header_factory (GtkColumnView *self, /** * gtk_column_view_scroll_to: * @self: The columnview to scroll in - * @pos: position of the item + * @pos: position of the item. Must be less than the number of + * items in the view. * @column: (nullable) (transfer none): The column to scroll to * or %NULL to not scroll columns. * @flags: actions to perform @@ -2211,6 +2212,7 @@ gtk_column_view_scroll_to (GtkColumnView *self, GtkScrollInfo *scroll) { g_return_if_fail (GTK_IS_COLUMN_VIEW (self)); + g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self))); g_return_if_fail (column == NULL || GTK_IS_COLUMN_VIEW_COLUMN (column)); if (column) { diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c index 23a98f16c9163b9a1f433b4a25768b0caa571cf7..2aede73ddf77321dd92c0745249f95edc8aa1e1b 100644 --- a/gtk/gtkgridview.c +++ b/gtk/gtkgridview.c @@ -1576,7 +1576,8 @@ gtk_grid_view_get_tab_behavior (GtkGridView *self) /** * gtk_grid_view_scroll_to: * @self: The gridview to scroll in - * @pos: position of the item + * @pos: position of the item. Must be less than the number of + * items in the view. * @flags: actions to perform * @scroll: (nullable) (transfer full): details of how to perform * the scroll operation or %NULL to scroll into view @@ -1596,6 +1597,7 @@ gtk_grid_view_scroll_to (GtkGridView *self, GtkScrollInfo *scroll) { g_return_if_fail (GTK_IS_GRID_VIEW (self)); + g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self))); gtk_list_base_scroll_to (GTK_LIST_BASE (self), pos, flags, scroll); } diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c index 62be81671c585ce961f7541272e15c8c85637ee2..c7933621a20b03ab2446e08e29d367b20a7de30e 100644 --- a/gtk/gtklistview.c +++ b/gtk/gtklistview.c @@ -1356,7 +1356,8 @@ gtk_list_view_get_tab_behavior (GtkListView *self) /** * gtk_list_view_scroll_to: * @self: The listview to scroll in - * @pos: position of the item + * @pos: position of the item. Must be less than the number of + * items in the view. * @flags: actions to perform * @scroll: (nullable) (transfer full): details of how to perform * the scroll operation or %NULL to scroll into view @@ -1376,6 +1377,7 @@ gtk_list_view_scroll_to (GtkListView *self, GtkScrollInfo *scroll) { g_return_if_fail (GTK_IS_LIST_VIEW (self)); + g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self))); gtk_list_base_scroll_to (GTK_LIST_BASE (self), pos, flags, scroll); }