diff -r 799c8f60b9f1 -r 1c3af8e31d8e ui/common/toolbar.c --- a/ui/common/toolbar.c Tue Oct 29 10:43:59 2024 +0100 +++ b/ui/common/toolbar.c Tue Oct 29 11:17:59 2024 +0100 @@ -27,6 +27,7 @@ */ #include "toolbar.h" +#include "menu.h" #include @@ -47,25 +48,26 @@ return str ? strdup(str) : NULL; } -static UiToolbarItemArgs itemargs_copy(UiToolbarItemArgs args) { +static UiToolbarItemArgs itemargs_copy(UiToolbarItemArgs args, size_t *ngroups) { UiToolbarItemArgs newargs; newargs.label = nl_strdup(args.label); newargs.stockid = nl_strdup(args.stockid); newargs.icon = nl_strdup(args.icon); newargs.onclick = args.onclick; newargs.onclickdata = args.onclickdata; + newargs.groups = uic_copy_groups(args.groups, ngroups); return newargs; } void ui_toolbar_item_create(const char* name, UiToolbarItemArgs args) { UiToolbarItem* item = malloc(sizeof(UiToolbarItem)); item->item.type = UI_TOOLBAR_ITEM; - item->args = itemargs_copy(args); + item->args = itemargs_copy(args, &item->ngroups); cxMapPut(toolbar_items, name, item); } -static UiToolbarToggleItemArgs toggleitemargs_copy(UiToolbarToggleItemArgs args) { +static UiToolbarToggleItemArgs toggleitemargs_copy(UiToolbarToggleItemArgs args, size_t *ngroups) { UiToolbarToggleItemArgs newargs; newargs.label = nl_strdup(args.label); newargs.stockid = nl_strdup(args.stockid); @@ -73,13 +75,14 @@ newargs.varname = nl_strdup(args.varname); newargs.onchange = args.onchange; newargs.onchangedata = args.onchangedata; + newargs.groups = uic_copy_groups(args.groups, ngroups); return newargs; } void ui_toolbar_toggleitem_create(const char* name, UiToolbarToggleItemArgs args) { UiToolbarToggleItem* item = malloc(sizeof(UiToolbarToggleItem)); item->item.type = UI_TOOLBAR_TOGGLEITEM; - item->args = toggleitemargs_copy(args); + item->args = toggleitemargs_copy(args, &item->ngroups); cxMapPut(toolbar_items, name, item); }