ui/common/context.c

changeset 1089
a3db51a94b37
parent 1066
afe02792303d
--- a/ui/common/context.c	Tue Apr 14 18:08:20 2026 +0200
+++ b/ui/common/context.c	Wed Apr 15 11:19:25 2026 +0200
@@ -81,6 +81,8 @@
     }
 #endif
     
+    ctx->ref = 1;
+    
     return ctx;
 }
 
@@ -100,6 +102,25 @@
     cxListClear(ctx->state_widgets);
 }
 
+void uic_context_destroy(UiContext *ctx, void *document) {
+    if(!ctx) {
+        return;
+    }
+    
+    UiEvent ev;
+    ev.window = NULL;
+    ev.document = document;
+    ev.obj = NULL;
+    ev.eventdata = NULL;
+    ev.eventdatatype = 0;
+    ev.intval = 0;
+
+    if(ctx->close_callback) {
+        ctx->close_callback(&ev, ctx->close_data);
+    }
+    cxMempoolFree(ctx->mp);
+}
+
 void uic_context_attach_document(UiContext *ctx, void *document) {
     if(ctx->single_document_mode) {
         if(ctx->document) {

mercurial