# HG changeset patch # User Olaf Wintermann # Date 1780598131 -7200 # Node ID c69f2941d536bbeacc22defa21be0c12d881eec0 # Parent 2f9d8af6a49956a392e6d798ac263cc0ff9c12c2 save selections when copying bindings, fix invalid selections in gtk4 column view diff -r 2f9d8af6a499 -r c69f2941d536 ui/common/context.c --- a/ui/common/context.c Thu Jun 04 19:59:58 2026 +0200 +++ b/ui/common/context.c Thu Jun 04 20:35:31 2026 +0200 @@ -139,6 +139,10 @@ } void uic_context_update_bindings(UiContext *ctx) { + int onchange_enabled = ui_onchange_events_is_enabled(); + int onselection_enabled = ui_selection_events_is_enabled(); + ui_onchange_events_enable(FALSE); + ui_selection_events_enable(FALSE); // if a document variable has the same name as a parent variable, // move the bindings to the document UiContext *var_ctx = ctx->parent; @@ -167,6 +171,8 @@ uic_context_update_bindings(subctx); } } + ui_onchange_events_enable(onchange_enabled); + ui_selection_events_enable(onselection_enabled); } void uic_context_attach_document(UiContext *ctx, void *document) { @@ -187,7 +193,10 @@ } static void uic_context_unbind_vars(UiContext *ctx) { + int onchange_enabled = ui_onchange_events_is_enabled(); + int onselection_enabled = ui_selection_events_is_enabled(); ui_onchange_events_enable(FALSE); + ui_selection_events_enable(FALSE); CxMapIterator mi = cxMapIterator(ctx->vars); cx_foreach(CxMapEntry*, entry, mi) { //printf("detach %.*s\n", (int)entry->key->len, (char*)entry->key->data); @@ -210,7 +219,8 @@ } } - ui_onchange_events_enable(TRUE); + ui_onchange_events_enable(onchange_enabled); + ui_selection_events_enable(onselection_enabled); } void uic_context_detach_document(UiContext *ctx, void *document) { @@ -464,6 +474,14 @@ case UI_VAR_LIST: { UiList *f = from; UiList *t = to; + // save selection + ui_list_selection_free(f->saved_selection); + if(f->getselection && f->save_selection) { + f->saved_selection = ui_list_get_selection_allocated(f); + } else { + f->saved_selection = NULL; + } + uic_list_copy(f, t); ui_list_update(t); if(t->setselection && t->saved_selection) { diff -r 2f9d8af6a499 -r c69f2941d536 ui/gtk/list.c --- a/ui/gtk/list.c Thu Jun 04 19:59:58 2026 +0200 +++ b/ui/gtk/list.c Thu Jun 04 20:35:31 2026 +0200 @@ -938,6 +938,9 @@ if(i < 0) { cxMapClear(view->bound_rows); ui_update_liststore(view->liststore, list); + free(view->selection.rows); + view->selection.rows = NULL; + view->selection.count = 0; } else { void *value = list->get(list, i); if(value) {