ui/common/context.c

changeset 1094
c0eb2bc7ab13
parent 1092
0accf125a65f
child 1097
d44c895e9ee9
equal deleted inserted replaced
1093:1686de34a489 1094:c0eb2bc7ab13
131 cxListAdd(ctx->documents, document); 131 cxListAdd(ctx->documents, document);
132 ctx->document = document; 132 ctx->document = document;
133 133
134 UiContext *doc_ctx = ui_document_context(document); 134 UiContext *doc_ctx = ui_document_context(document);
135 doc_ctx->parent = ctx; 135 doc_ctx->parent = ctx;
136 doc_ctx->ref++;
136 137
137 // if a document variable has the same name as a parent variable, 138 // if a document variable has the same name as a parent variable,
138 // move the bindings to the document 139 // move the bindings to the document
139 UiContext *var_ctx = ctx; 140 UiContext *var_ctx = ctx;
140 while(var_ctx) { 141 while(var_ctx) {
150 } 151 }
151 } 152 }
152 153
153 var_ctx = var_ctx->parent; 154 var_ctx = var_ctx->parent;
154 } 155 }
155 156
156 ui_update_action_bindings(ctx); 157 ui_update_action_bindings(ctx);
157 } 158 }
158 159
159 static void uic_context_unbind_vars(UiContext *ctx) { 160 static void uic_context_unbind_vars(UiContext *ctx) {
160 ui_onchange_events_enable(FALSE); 161 ui_onchange_events_enable(FALSE);
194 ctx->document = cxListAt(ctx->documents, 0); 195 ctx->document = cxListAt(ctx->documents, 0);
195 196
196 UiContext *docctx = ui_document_context(document); 197 UiContext *docctx = ui_document_context(document);
197 uic_context_unbind_vars(docctx); // unbind all doc/subdoc vars from the parent 198 uic_context_unbind_vars(docctx); // unbind all doc/subdoc vars from the parent
198 docctx->parent = NULL; 199 docctx->parent = NULL;
200 ui_document_unref(document);
199 201
200 ui_update_action_bindings(ctx); 202 ui_update_action_bindings(ctx);
201 } 203 }
202 204
203 void uic_context_detach_all(UiContext *ctx) { 205 void uic_context_detach_all(UiContext *ctx) {

mercurial