GNOME Bugzilla – Bug 726859
[PATCH] Assertion/crash if gtk_radio_menu_item_set_group() is called twice
Last modified: 2014-03-27 00:38:48 UTC
Created attachment 272612 [details] [review] Fix assertion/crash If gtk_radio_menu_item_set_group() is passed the same group returned by gtk_radio_menu_item_get_group() for the same widget, GTK+ prints a warning (or crashes if compiled with --enable-debug=no). Calling gtk_radio_menu_item_set_group() in this case is pointless and should be a no-op, but it should not cause a crash. Example code to reproduce: -------------------- #include <gtk/gtk.h> int main (void) { gtk_init (NULL, NULL); GtkWidget * radio1 = gtk_radio_menu_item_new (NULL); GSList * group = gtk_radio_menu_item_get_group ((GtkRadioMenuItem *) radio1); gtk_radio_menu_item_set_group ((GtkRadioMenuItem *) radio1, group); return 0; } -------------------- This is currently causing Galculator (the GTK3 version) to crash on startup. Evidently GtkBuilder processes the "group" property twice in some cases (which is probably a separate bug). Snippet from running "GTK_DEBUG=builder galculator": -------------------- <child> <object class="GtkRadioMenuItem" id="hex"> <property name="visible"> </property> <property name="can_focus"> </property> <property name="use_action_appearance"> </property> <property name="label" translatable="yes"> </property> <property name="use_underline"> </property> <property name="group"> </property> <accelerator key="H" signal="activate" modifiers="GDK_CONTROL_MASK"> created hex of type GtkRadioMenuItem set hex: visible = TRUE set hex: can-focus = FALSE set hex: use-action-appearance = FALSE set hex: label = "_Hexadecimal" set hex: use-underline = TRUE set hex: group = ((GtkRadioMenuItem*) 0xe498b0) </accelerator> <signal name="toggled" handler="on_hex_toggled" swapped="no"> </signal> </object> (galculator:13925): Gtk-CRITICAL **: gtk_radio_menu_item_set_group: assertion '!g_slist_find (group, radio_menu_item)' failed set hex: group = ((GtkRadioMenuItem*) 0xe498b0) set hex: use-underline = TRUE set hex: label = "_Hexadecimal" set hex: use-action-appearance = FALSE set hex: can-focus = FALSE set hex: visible = TRUE </child> adding hex to base_units_menu --------------------
Review of attachment 272612 [details] [review]: sure, doesn't hurt to allow this.