[gtk+/gtk-3-20] menuitem: Fix some possible problems with arrow_gadget



commit 6e00717079505fd671d69befbfd75ce2a640b28d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Apr 17 01:09:32 2016 -0400

    menuitem: Fix some possible problems with arrow_gadget
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765134 shows
    a stacktrace where we end up with arrow_gadget being NULL
    despite the conditions for its presence being satisfied.
    
    This commit makes sure we call update_arrow_gadget() whenever
    any of the conditions changes. This should fix the reported
    crash.

 gtk/gtkmenuitem.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 419f4c5..65af892 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -1528,7 +1528,10 @@ gtk_menu_item_set_submenu (GtkMenuItem *menu_item,
   if (priv->submenu != submenu)
     {
       if (priv->submenu)
-        gtk_menu_detach (GTK_MENU (priv->submenu));
+        {
+          gtk_menu_detach (GTK_MENU (priv->submenu));
+          priv->submenu = NULL;
+        }
 
       if (submenu)
         {
@@ -1536,10 +1539,10 @@ gtk_menu_item_set_submenu (GtkMenuItem *menu_item,
           gtk_menu_attach_to_widget (GTK_MENU (submenu),
                                      widget,
                                      gtk_menu_item_detacher);
-
-          update_arrow_gadget (menu_item);
         }
 
+      update_arrow_gadget (menu_item);
+
       if (gtk_widget_get_parent (widget))
         gtk_widget_queue_resize (widget);
 
@@ -2348,6 +2351,8 @@ gtk_menu_item_parent_set (GtkWidget *widget,
                                        menu->priv->accel_group,
                                        TRUE);
 
+  update_arrow_gadget (menu_item);
+
   if (GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->parent_set)
     GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->parent_set (widget, previous_parent);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]