# HG changeset patch # User Olaf Wintermann # Date 1776353801 -7200 # Node ID ab2e458df182a3897fdff465575815658cbc0343 # Parent a3db51a94b3729836a358ec09044d68cc3c973f0 fix new UiModel reference counter diff -r a3db51a94b37 -r ab2e458df182 ui/common/types.c --- a/ui/common/types.c Wed Apr 15 11:19:25 2026 +0200 +++ b/ui/common/types.c Thu Apr 16 17:36:41 2026 +0200 @@ -224,6 +224,7 @@ UiModel* ui_model(UiContext *ctx, ...) { UiModel *info = ui_calloc(ctx, 1, sizeof(UiModel)); info->ctx = ctx; + info->ref = 1; va_list ap; va_start(ap, ctx); @@ -275,6 +276,7 @@ UiModel* ui_model_new(UiContext *ctx) { UiModel *info = ui_calloc(ctx, 1, sizeof(UiModel)); info->ctx = ctx; + info->ref = 1; info->alloc = UI_MODEL_DEFAULT_ALLOC_SIZE; info->types = ui_calloc(ctx, UI_MODEL_DEFAULT_ALLOC_SIZE, sizeof(UiModelType)); info->titles = ui_calloc(ctx, UI_MODEL_DEFAULT_ALLOC_SIZE, sizeof(char*)); @@ -371,7 +373,7 @@ void ui_model_free(UiModel *mi) { UiContext *ctx = mi->ctx; - const CxAllocator* a = ctx->allocator; + const CxAllocator* a = ctx ? ctx->allocator : cxDefaultAllocator; for(int i=0;icolumns;i++) { ui_free(ctx, mi->titles[i]); }