diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2015-12-29 18:31:10 -0800 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2015-12-29 18:31:10 -0800 |
commit | 354eb5678b13d101bd097e038245be1a7a4aed9c (patch) | |
tree | c682022df9e917358178743442491d3a4fa2ff65 /gtk/gtkmenuitem.c | |
parent | 3740c7f09265e952e92566045c69edec50ad9b1a (diff) | |
download | gtk+-354eb5678b13d101bd097e038245be1a7a4aed9c.tar.gz |
menuitem: fix a crash when reserve_indicator is TRUE
In that case, code expects an arrow gadget to be present but we're not
creating it in every occurrence.
Fix it by ensuring there will be an arrow gadget when reserve_indicator
is TRUE.
Diffstat (limited to 'gtk/gtkmenuitem.c')
-rw-r--r-- | gtk/gtkmenuitem.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 10c2cbd3ae..76f7052185 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -1503,6 +1503,33 @@ update_node_classes (GtkMenuItem *menu_item) } } +static void +update_arrow_gadget (GtkMenuItem *menu_item) +{ + GtkMenuItemPrivate *priv = menu_item->priv; + GtkWidget *widget = GTK_WIDGET (menu_item); + gboolean should_have_gadget; + + should_have_gadget = priv->reserve_indicator || + (priv->submenu && !GTK_IS_MENU_BAR (gtk_widget_get_parent (widget))); + + if (should_have_gadget) + { + if (!priv->arrow_gadget) + { + priv->arrow_gadget = gtk_builtin_icon_new ("arrow", + widget, + priv->gadget, + NULL); + update_node_classes (menu_item); + } + } + else + { + g_clear_object (&priv->arrow_gadget); + } +} + /** * gtk_menu_item_set_submenu: * @menu_item: a #GtkMenuItem @@ -1536,14 +1563,7 @@ gtk_menu_item_set_submenu (GtkMenuItem *menu_item, widget, gtk_menu_item_detacher); - if (!GTK_IS_MENU_BAR (gtk_widget_get_parent (widget))) - { - priv->arrow_gadget = gtk_builtin_icon_new ("arrow", - widget, - priv->gadget, - NULL); - update_node_classes (menu_item); - } + update_arrow_gadget (menu_item); } if (gtk_widget_get_parent (widget)) @@ -2666,6 +2686,7 @@ gtk_menu_item_set_reserve_indicator (GtkMenuItem *menu_item, if (priv->reserve_indicator != reserve) { priv->reserve_indicator = reserve; + update_arrow_gadget (menu_item); gtk_widget_queue_resize (GTK_WIDGET (menu_item)); } } |