ui/gtk/list.c

changeset 580
9b8d61227169
parent 504
f0c21da35aa4
child 591
637de2359995
--- a/ui/gtk/list.c	Mon Apr 21 11:03:17 2025 +0200
+++ b/ui/gtk/list.c	Mon Apr 21 19:32:57 2025 +0200
@@ -587,7 +587,12 @@
             ObjWrapper *obj = obj_wrapper_new(value);
             // TODO: if index i is selected, the selection is lost
             // is it possible to update the item without removing it?
-            g_list_store_splice(view->liststore, i, 1, (void **)&obj, 1);
+            int count = g_list_model_get_n_items(G_LIST_MODEL(view->liststore));
+            if(count <= i) {
+                g_list_store_splice(view->liststore, i, 0, (void **)&obj, 1);
+            } else {
+                g_list_store_splice(view->liststore, i, 1, (void **)&obj, 1);
+            }
         }
     }
 }

mercurial