]> uap-core.de Git - note.git/commitdiff
fix list update after note creation (GTK4)
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 21 Apr 2025 16:58:52 +0000 (18:58 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 21 Apr 2025 16:58:52 +0000 (18:58 +0200)
ui/gtk/list.c

index 274322089c6d30d6f727568e2f7a7204126962b1..af11158166b71289a9a740211d6ff3743f5ff934 100644 (file)
@@ -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);
+            }
         }
     }
 }