ui/common/context.c

changeset 101
7b3a3130be44
parent 100
d2bd73d28ff1
equal deleted inserted replaced
100:d2bd73d28ff1 101:7b3a3130be44
98 UiContext *var_ctx = ctx; 98 UiContext *var_ctx = ctx;
99 while(var_ctx) { 99 while(var_ctx) {
100 if(var_ctx->vars_unbound && cxMapSize(var_ctx->vars_unbound) > 0) { 100 if(var_ctx->vars_unbound && cxMapSize(var_ctx->vars_unbound) > 0) {
101 CxIterator i = cxMapIterator(var_ctx->vars_unbound); 101 CxIterator i = cxMapIterator(var_ctx->vars_unbound);
102 cx_foreach(CxMapEntry*, entry, i) { 102 cx_foreach(CxMapEntry*, entry, i) {
103 printf("attach %s\n", entry->key->data);
103 UiVar *var = entry->value; 104 UiVar *var = entry->value;
104 UiVar *docvar = cxMapGet(doc_ctx->vars, *entry->key); 105 UiVar *docvar = cxMapGet(doc_ctx->vars, *entry->key);
105 if(docvar) { 106 if(docvar) {
106 // bind var to document var 107 // bind var to document var
107 uic_copy_binding(var, docvar, TRUE); 108 uic_copy_binding(var, docvar, TRUE);
161 i = cxListIterator(ls); 162 i = cxListIterator(ls);
162 cx_foreach(void *, doc, i) { 163 cx_foreach(void *, doc, i) {
163 ctx->detach_document2(ctx, doc); 164 ctx->detach_document2(ctx, doc);
164 } 165 }
165 166
166 cxListDestroy(ls); 167 cxListFree(ls);
167 } 168 }
168 169
169 static UiVar* ctx_getvar(UiContext *ctx, CxHashKey key) { 170 static UiVar* ctx_getvar(UiContext *ctx, CxHashKey key) {
170 UiVar *var = cxMapGet(ctx->vars, key); 171 UiVar *var = cxMapGet(ctx->vars, key);
171 if(!var && ctx->documents) { 172 if(!var && ctx->documents) {
463 ctx->close_callback = fnc; 464 ctx->close_callback = fnc;
464 ctx->close_data = udata; 465 ctx->close_data = udata;
465 } 466 }
466 467
467 UIEXPORT void ui_context_destroy(UiContext *ctx) { 468 UIEXPORT void ui_context_destroy(UiContext *ctx) {
468 cxMempoolDestroy(ctx->mp); 469 cxMempoolFree(ctx->mp);
469 } 470 }
470 471
471 472
472 void ui_set_group(UiContext *ctx, int group) { 473 void ui_set_group(UiContext *ctx, int group) {
473 if(cxListFind(ctx->groups, &group) == -1) { 474 if(cxListFind(ctx->groups, &group) == -1) {
532 } 533 }
533 va_end(ap); 534 va_end(ap);
534 535
535 uic_add_group_widget(ctx, widget, enable, groups); 536 uic_add_group_widget(ctx, widget, enable, groups);
536 537
537 cxListDestroy(groups); 538 cxListFree(groups);
538 } 539 }
539 540
540 size_t uic_group_array_size(const int *groups) { 541 size_t uic_group_array_size(const int *groups) {
541 int i; 542 int i;
542 for(i=0;groups[i] >= 0;i++) { } 543 for(i=0;groups[i] >= 0;i++) { }

mercurial