From 07976be6d10edcd04959eb73455cd7ee3c8720a5 Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Mon, 19 Oct 2026 13:46:33 +0200 Subject: [PATCH] treestore: check the first child when moving after nothing --- gtk/gtktreestore.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c index 91f43bfe6..b1dd27eaf 100644 --- a/gtk/gtktreestore.c +++ b/gtk/gtktreestore.c @@ -2515,15 +2515,13 @@ gtk_tree_store_move (GtkTreeStore *tree_store, } else { - /* move after without position is prepending */ - if (depth) - gtk_tree_store_iter_children (GTK_TREE_MODEL (tree_store), &dst_b, - &parent_iter); + /* move after without position is prepending; the row that + * moves is one of the children, so there is a first one */ + if (gtk_tree_store_iter_children (GTK_TREE_MODEL (tree_store), &dst_b, + depth ? &parent_iter : NULL)) + b = G_NODE (dst_b.user_data); else - gtk_tree_store_iter_children (GTK_TREE_MODEL (tree_store), &dst_b, - NULL); - - b = G_NODE (dst_b.user_data); + b = NULL; } /* if a is NULL, b is NULL too -- we are at the end of the list