2 weeks ago
fix UiContext detaching
ui/common/context.c | file | annotate | diff | comparison | revisions |
--- a/ui/common/context.c Sun Feb 23 14:55:23 2025 +0100 +++ b/ui/common/context.c Sun Feb 23 17:10:45 2025 +0100 @@ -92,6 +92,7 @@ ctx->document = document; UiContext *doc_ctx = ui_document_context(document); + doc_ctx->parent = ctx; // check if any parent context has an unbound variable with the same name // as any document variable @@ -111,7 +112,7 @@ } } - var_ctx = ctx->parent; + var_ctx = var_ctx->parent; } } @@ -119,7 +120,7 @@ CxMapIterator mi = cxMapIterator(ctx->vars); cx_foreach(CxMapEntry*, entry, mi) { UiVar *var = entry->value; - if(var->from && var->from_ctx) { + if(var->from && var->from_ctx && var->from_ctx != ctx) { uic_save_var2(var); uic_copy_binding(var, var->from, FALSE); cxMapPut(var->from_ctx->vars_unbound, *entry->key, var->from); @@ -148,6 +149,7 @@ UiContext *docctx = ui_document_context(document); uic_context_unbind_vars(docctx); // unbind all doc/subdoc vars from the parent + docctx->parent = NULL; } void uic_context_detach_all(UiContext *ctx) {