[gedit] Add a workaround to avoid criticals on shutdown



commit efdc78936888dbe5ea7359535427715b2ec20d78
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Feb 18 14:07:25 2014 +0100

    Add a workaround to avoid criticals on shutdown

 gedit/gedit-menu-stack-switcher.c |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/gedit/gedit-menu-stack-switcher.c b/gedit/gedit-menu-stack-switcher.c
index 0594c3d..ec8fc88 100644
--- a/gedit/gedit-menu-stack-switcher.c
+++ b/gedit/gedit-menu-stack-switcher.c
@@ -111,22 +111,33 @@ update_button (GeditMenuStackSwitcher *switcher,
                GtkWidget              *button)
 {
   GeditMenuStackSwitcherPrivate *priv = switcher->priv;
-  gchar *title;
+  GList *children;
 
-  gtk_container_child_get (GTK_CONTAINER (priv->stack), widget,
-                           "title", &title,
-                           NULL);
+  /* We get spurious notifications while the stack is being
+   * destroyed, so for now check the child actually exists
+   */
+  children = gtk_container_get_children (GTK_CONTAINER (priv->stack));
+  if (g_list_index (children, widget) >= 0)
+    {
+      gchar *title;
 
-  gtk_button_set_label (GTK_BUTTON (button), title);
-  gtk_widget_set_visible (button, gtk_widget_get_visible (widget) && (title != NULL));
-  gtk_widget_set_size_request (button, 100, -1);
+      gtk_container_child_get (GTK_CONTAINER (priv->stack), widget,
+                               "title", &title,
+                               NULL);
 
-  if (widget == gtk_stack_get_visible_child (priv->stack))
-    {
-      gtk_label_set_label (GTK_LABEL (priv->label), title);
+      gtk_button_set_label (GTK_BUTTON (button), title);
+      gtk_widget_set_visible (button, gtk_widget_get_visible (widget) && (title != NULL));
+      gtk_widget_set_size_request (button, 100, -1);
+
+      if (widget == gtk_stack_get_visible_child (priv->stack))
+        {
+          gtk_label_set_label (GTK_LABEL (priv->label), title);
+        }
+
+      g_free (title);
     }
 
-  g_free (title);
+   g_list_free (children);
 }
 
 static void


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