diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c index f95738bfce..1aa825c229 100644 --- a/gtk/gtkcolumnview.c +++ b/gtk/gtkcolumnview.c @@ -2184,7 +2184,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 @@ -2207,6 +2208,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 b2636c915a..0fdebb1822 100644 --- a/gtk/gtkgridview.c +++ b/gtk/gtkgridview.c @@ -1574,7 +1574,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 @@ -1594,6 +1595,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 53e8558dd8..7b1b423b79 100644 --- a/gtk/gtklistview.c +++ b/gtk/gtklistview.c @@ -1352,7 +1352,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 @@ -1372,6 +1373,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); }