fix attaching documents increases the reference counter default tip

Sat, 18 Apr 2026 08:07:24 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 18 Apr 2026 08:07:24 +0200
changeset 1094
c0eb2bc7ab13
parent 1093
1686de34a489

fix attaching documents increases the reference counter

ui/common/context.c file | annotate | diff | comparison | revisions
--- a/ui/common/context.c	Fri Apr 17 14:50:31 2026 +0200
+++ b/ui/common/context.c	Sat Apr 18 08:07:24 2026 +0200
@@ -133,6 +133,7 @@
     
     UiContext *doc_ctx = ui_document_context(document);
     doc_ctx->parent = ctx;
+    doc_ctx->ref++;
     
     // if a document variable has the same name as a parent variable,
     // move the bindings to the document
@@ -152,7 +153,7 @@
         
         var_ctx = var_ctx->parent;
     }
-    
+      
     ui_update_action_bindings(ctx);
 }
 
@@ -196,6 +197,7 @@
     UiContext *docctx = ui_document_context(document);
     uic_context_unbind_vars(docctx); // unbind all doc/subdoc vars from the parent
     docctx->parent = NULL;
+    ui_document_unref(document);
     
     ui_update_action_bindings(ctx);
 }

mercurial