After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 726859 - [PATCH] Assertion/crash if gtk_radio_menu_item_set_group() is called twice
[PATCH] Assertion/crash if gtk_radio_menu_item_set_group() is called twice
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkMenu
3.10.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-03-22 03:12 UTC by John Lindgren
Modified: 2014-03-27 00:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix assertion/crash (964 bytes, patch)
2014-03-22 03:12 UTC, John Lindgren
committed Details | Review

Description John Lindgren 2014-03-22 03:12:39 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

--------------------
Comment 1 Matthias Clasen 2014-03-22 19:35:29 UTC
Review of attachment 272612 [details] [review]:

sure, doesn't hurt to allow this.