ui/common/types.c

changeset 1088
09459f07ab11
parent 1068
1c79dbd248f4
--- a/ui/common/types.c	Sat Apr 11 16:29:40 2026 +0200
+++ b/ui/common/types.c	Tue Apr 14 18:08:20 2026 +0200
@@ -100,6 +100,7 @@
 /* --------------------------- UiList --------------------------- */
 
 void uic_ucx_list_init(UiContext *ctx, UiList *list, void *unused) {
+    list->destroy = uic_ucx_list_destroy;
     list->data = cxArrayListCreate(ctx->mp->allocator, CX_STORE_POINTERS, 32);
     list->first = ui_list_first;
     list->next = ui_list_next;
@@ -129,7 +130,9 @@
 }
 
 void ui_list_free(UiContext *ctx, UiList *list) {
-    if(!default_list_destroy) {
+    if(list->destroy) {
+        list->destroy(ctx, list, NULL);
+    } else if(!default_list_destroy) {
         uic_ucx_list_destroy(ctx, list, NULL);
     } else {
         default_list_destroy(ctx, list, default_list_destroy_userdata);
@@ -935,6 +938,10 @@
     default_list_destroy_userdata = userdata;
 }
 
+UIEXPORT void ui_list_class_set_destructor(UiList *list, ui_list_destroy_func destroy) {
+    list->destroy = destroy;
+}
+
 void ui_list_class_set_first(UiList *list, void*(*first)(UiList *list)) {
     list->first = first;
 }

mercurial