From: Olaf Wintermann Date: Mon, 21 Apr 2025 16:58:52 +0000 (+0200) Subject: fix list update after note creation (GTK4) X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=511bf3334eeb910a4b11713075f95bf0693c5039;p=note.git fix list update after note creation (GTK4) --- 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); + } } } }