Mon, 21 Apr 2025 19:32:57 +0200
fix list update (GTK4)
| ui/gtk/list.c | file | annotate | diff | comparison | revisions |
--- 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); + } } } }