fix missing terminator in uic_copy_groups newapi

Tue, 26 Nov 2024 15:53:57 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 26 Nov 2024 15:53:57 +0100
branch
newapi
changeset 393
3099bf907e21
parent 392
df62b7205bd3
child 394
bedd499b640d

fix missing terminator in uic_copy_groups

ui/common/menu.c file | annotate | diff | comparison | revisions
ui/gtk/headerbar.c file | annotate | diff | comparison | revisions
--- a/ui/common/menu.c	Tue Nov 26 10:40:03 2024 +0100
+++ b/ui/common/menu.c	Tue Nov 26 15:53:57 2024 +0100
@@ -82,8 +82,9 @@
     for (n = 0; groups[n] > -1; n++) { }
 
     if (ngroups > 0) {
-        int* newarray = calloc(n, sizeof(int));
+        int* newarray = calloc(n+1, sizeof(int));
         memcpy(newarray, groups, n * sizeof(int));
+        newarray[n] = -1;
         *ngroups = n;
         return newarray;
     }
--- a/ui/gtk/headerbar.c	Tue Nov 26 10:40:03 2024 +0100
+++ b/ui/gtk/headerbar.c	Tue Nov 26 15:53:57 2024 +0100
@@ -115,6 +115,7 @@
         enum UiToolbarPos pos)
 {
     GtkWidget *button = ui_create_button(obj, item->args.label, item->args.icon, item->args.onclick, item->args.onclickdata, 0, FALSE);
+    ui_set_widget_groups(obj->ctx, button, item->args.groups);
     WIDGET_ADD_CSS_CLASS(button, "flat");
     headerbar_add(headerbar, box, button, pos);
 }
@@ -127,6 +128,7 @@
         enum UiToolbarPos pos)
 {
     GtkWidget *button = gtk_toggle_button_new();
+    ui_set_widget_groups(obj->ctx, button, item->args.groups);
     WIDGET_ADD_CSS_CLASS(button, "flat");
     ui_setup_togglebutton(obj, button, item->args.label, item->args.icon, item->args.varname, NULL, item->args.onchange, item->args.onchangedata, 0);
     headerbar_add(headerbar, box, button, pos);

mercurial