From 511bf3334eeb910a4b11713075f95bf0693c5039 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Mon, 21 Apr 2025 18:58:52 +0200 Subject: [PATCH] fix list update after note creation (GTK4) --- ui/gtk/list.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/gtk/list.c b/ui/gtk/list.c index 2743220..af11158 100644 --- a/ui/gtk/list.c +++ b/ui/gtk/list.c @@ -587,7 +587,12 @@ void ui_listview_update2(UiList *list, int i) { 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); + } } } } -- 2.43.5