--- a/ui/common/context.c Sun Apr 19 15:25:45 2026 +0200 +++ b/ui/common/context.c Sun Apr 19 20:05:11 2026 +0200 @@ -108,16 +108,23 @@ } UiEvent ev; - ev.window = NULL; + ev.obj = ctx->obj; + ev.window = ev.obj ? ev.obj->window : NULL; ev.document = document; - ev.obj = NULL; ev.eventdata = NULL; ev.eventdatatype = 0; ev.intval = 0; + ev.set = 0; if(ctx->close_callback) { ctx->close_callback(&ev, ctx->close_data); } + + CxIterator i = cxListIterator(ctx->destroy_handler); + cx_foreach(UiDestroyHandler *, h, i) { + h->destructor(h->data); + } + cxMempoolFree(ctx->mp); } @@ -552,14 +559,6 @@ ctx->close_data = udata; } -void ui_context_destroy(UiContext *ctx) { - CxIterator i = cxListIterator(ctx->destroy_handler); - cx_foreach(UiDestroyHandler *, h, i) { - h->destructor(h->data); - } - cxMempoolFree(ctx->mp); -} - UiContext* ui_context_parent(UiContext *ctx) { return ctx->parent; } @@ -730,7 +729,8 @@ } void ui_reg_destructor(UiContext *ctx, void *data, ui_destructor_func destr) { - cxMempoolRegister(ctx->mp, data, (cx_destructor_func)destr); + //cxMempoolRegister(ctx->mp, data, (cx_destructor_func)destr); + uic_context_add_destructor(ctx, destr, data); } void ui_set_destructor(void *mem, ui_destructor_func destr) {