diff -r c03c338a7dcf -r cc2170ea05ad ui/common/context.c --- a/ui/common/context.c Fri Nov 10 17:17:14 2017 +0100 +++ b/ui/common/context.c Fri Nov 10 18:04:40 2017 +0100 @@ -117,6 +117,7 @@ UcxMapIterator i = ucx_map_iterator(docctx->vars); UiVar *var; UCX_MAP_FOREACH(key, var, i) { + uic_save_var(var); if(var->from) { // restore old root bound var val var->from->value = var->from->orig_val; @@ -232,9 +233,6 @@ case UI_VAR_INTEGER: { UiInteger *f = from->value; UiInteger *t = to->value; - if(!copytodoc) { - f->value = f->get(f); - } uic_int_copy(f, t); if(t->value != 0) { t->set(t, t->value); @@ -245,26 +243,17 @@ UiString *f = from->value; UiString *t = to->value; uic_string_copy(f, t); - if(!copytodoc) { - f->value = f->get(f); - } else { - char *tvalue = t->value ? t->value : ""; - t->set(t, tvalue); - } - + char *tvalue = t->value.ptr ? t->value.ptr : ""; + t->set(t, tvalue); break; } case UI_VAR_TEXT: { UiText *f = from->value; UiText *t = to->value; uic_text_copy(f, t); - if(!copytodoc) { - f->value = f->get(f); - } else { - char *tvalue = t->value ? t->value : ""; - t->set(t, tvalue); - t->setposition(t, t->pos); - } + char *tvalue = t->value.ptr ? t->value.ptr : ""; + t->set(t, tvalue); + t->setposition(t, t->pos); break; } case UI_VAR_LIST: { @@ -276,9 +265,6 @@ case UI_VAR_RANGE: { UiRange *f = from->value; UiRange *t = to->value; - if(!copytodoc) { - f->value = f->get(f); - } uic_range_copy(f, t); t->setextent(t, t->extent); t->setrange(t, t->min, t->max); @@ -294,6 +280,16 @@ } } +void uic_save_var(UiVar *var) { + switch(var->type) { + case UI_VAR_INTEGER: uic_int_save(var->value); break; + case UI_VAR_STRING: uic_string_save(var->value); break; + case UI_VAR_TEXT: uic_text_save(var->value); break; + case UI_VAR_LIST: break; + case UI_VAR_RANGE: uic_range_save(var->value); break; + } +} + void uic_unbind_var(UiVar *var) { switch(var->type) { case UI_VAR_INTEGER: uic_int_unbind(var->value); break;