void notebookmodel_attach_note(NotebookModel *model, Note *note) {
- if(model->current_note == note) {
- return; // NOOP
- }
+ // TODO: enable this optimization when possible
+ // currently, a reattaching a notebook will still have current_note
+ // but the UI binding will not be enabled
+ //if(model->current_note == note) {
+ // return; // NOOP
+ //}
if(note && !note->model) {
NoteModel *notemodel = notemodel_create(model->current_notes_pool->allocator);
}
notebookmodel_detach_current_note(model);
- ui_attach_document(model->window->obj->ctx, note->model);
+ ui_attach_document(model->ctx, note->model);
// TODO: this is only a workaround and should be removed when
// sub-document groups are supported
ui_set_group(model->window->obj->ctx, APP_STATE_NOTE_SELECTED);
void notebookmodel_detach_current_note(NotebookModel *model) {
if(model->current_note && model->current_note->model) {
- ui_detach_document2(model->window->obj->ctx, model->current_note->model);
+ ui_detach_document2(model->ctx, model->current_note->model);
model->current_note = NULL;
}
}
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
}
}
- var_ctx = ctx->parent;
+ var_ctx = var_ctx->parent;
}
}
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);
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) {