From 1c4583ef49ffe3527161e4552a4d75135958c7b9 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Tue, 13 May 2025 20:20:38 +0200 Subject: [PATCH] fix sidebar update --- ui/gtk/list.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/gtk/list.c b/ui/gtk/list.c index af11158..e5ffa58 100644 --- a/ui/gtk/list.c +++ b/ui/gtk/list.c @@ -1810,7 +1810,7 @@ UIEXPORT UIWIDGET ui_sourcelist_create(UiObject *obj, UiSourceListArgs args) { list->obj = uilistbox; list->update = ui_listbox_dynamic_update; - ui_listbox_dynamic_update(list, 0); + ui_listbox_dynamic_update(list, -1); } } @@ -1843,6 +1843,15 @@ void ui_listbox_dynamic_update(UiList *list, int x) { // unbind/free previous list vars CxIterator i = cxListIterator(uilistbox->sublists); cx_foreach(UiListBoxSubList *, s, i) { + // TODO: "unbind/free previous list vars" will also remove + // the widget list. This makes the widget optimization + // in ui_listbox_update_sublist pointless + // Is it actually possible to not recreate the whole list? + CxIterator r = cxListIterator(s->widgets); + cx_foreach(GtkWidget*, widget, r) { + LISTBOX_REMOVE(uilistbox->listbox, widget); + } + if(s->var) { UiList *sl = s->var->value; sl->obj = NULL; -- 2.43.5