diff -r 1f419bd32da1 -r eb5269000bc8 ui/common/context.c --- a/ui/common/context.c Sat Dec 07 12:14:59 2013 +0100 +++ b/ui/common/context.c Sun Dec 08 11:20:41 2013 +0000 @@ -33,9 +33,6 @@ #include "context.h" #include "../ui/window.h" -void uic_docmgr_init() { - -} UiContext* uic_context(UiObject *toplevel, UcxMempool *mp) { UiContext *ctx = ucx_mempool_malloc(mp, sizeof(UiContext)); @@ -50,14 +47,22 @@ } UiVar* uic_getvar(UiObject *obj, char *name) { + if(!obj) { + return NULL; + } return ucx_map_cstr_get(obj->ctx->vars, name); } -UiVar* uic_addplaceholder(UiObject *obj, char *name) { - UiVar *var = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiVar)); - var->type = -1; - var->value = NULL; - ucx_map_cstr_put(obj->ctx->vars, name, var); +void uic_rmvar(UiObject *obj, char *name) { + if(obj) { + UiVar *var = uic_getvar(obj, name); + if(var) { + if(var->isextern) { + ucx_mempool_free(obj->ctx->mempool, var->value); + } + ucx_mempool_free(obj->ctx->mempool, var); + } + } } void ui_window_addint(UiObject *obj, char *name) { @@ -66,7 +71,11 @@ return; } UiInteger *i = ucx_mempool_calloc(obj->ctx->mempool, 1, sizeof(UiInteger)); - ui_window_regint(obj, name, i); + UiVar *var = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiVar)); + var->value = i; + var->type = 1; + var->isextern = 0; + ucx_map_cstr_put(obj->ctx->vars, name, var); } void ui_window_regint(UiObject *obj, char *name, UiInteger *i) { @@ -77,6 +86,7 @@ UiVar *var = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiVar)); var->value = i; var->type = 1; + var->isextern = 1; ucx_map_cstr_put(obj->ctx->vars, name, var); }