fix double free on radiobutton group destroy newapi

Sun, 31 Mar 2024 09:58:07 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 31 Mar 2024 09:58:07 +0200
branch
newapi
changeset 274
9e2aee097b69
parent 273
1dd2456c51d3
child 275
132c7bcc6997

fix double free on radiobutton group destroy

ui/gtk/button.c file | annotate | diff | comparison | revisions
--- a/ui/gtk/button.c	Sun Mar 31 09:50:49 2024 +0200
+++ b/ui/gtk/button.c	Sun Mar 31 09:58:07 2024 +0200
@@ -197,9 +197,13 @@
         var = uic_create_var(obj->ctx, args.varname, UI_VAR_INTEGER);
     }
     
+    UiBool first = FALSE;
     if(var) {
         rgroup = var->value;
         rg = rgroup->obj;
+        if(!rg) {
+            first = TRUE;
+        }
     }
     
     GtkWidget *rbutton = gtk_radio_button_new_with_label(rg, args.label ? args.label : "");
@@ -224,11 +228,13 @@
                 "clicked",
                 G_CALLBACK(ui_radio_obs),
                 event);
-        g_signal_connect(
+        if(first) {
+            g_signal_connect(
                 rbutton,
                 "destroy",
                 G_CALLBACK(ui_destroy_vardata),
                 event);
+        }
     }
     
     UiContainer *ct = uic_get_current_container(obj);

mercurial