]> Pileus Git - ~andy/gtk/commitdiff
Short-circuit on destroy. (gtk_notebook_destroy): Destroy tab_label
authorMatthias Clasen <mclasen@redhat.com>
Mon, 26 Nov 2007 18:21:13 +0000 (18:21 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 26 Nov 2007 18:21:13 +0000 (18:21 +0000)
2007-11-26  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtknotebook.c (gtk_notebook_update_labels): Short-circuit on
        destroy.
        (gtk_notebook_destroy): Destroy tab_label widgets. (#388321, Morten
        Welinder)

svn path=/trunk/; revision=19059

ChangeLog
gtk/gtknotebook.c

index 1eaae0a99a25da741e372b8831b1adf1035d7eaa..5dcbeca0efa161faa12adeacc25a70c598ffbdb0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-11-26  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtknotebook.c (gtk_notebook_update_labels): Short-circuit on
+       destroy.
+       (gtk_notebook_destroy): Destroy tab_label widgets. (#388321, Morten
+       Welinder)
+
 2007-11-26  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkassistant.c: Improve alternative button
index eb201c5768de6419f2301fbd9c46b2036120ba60..c78a9a84da9a840ee1eef2a01a84ba7dc06f0837 100644 (file)
@@ -212,6 +212,8 @@ static void     gtk_notebook_move_focus_out      (GtkNotebook      *notebook,
 static gboolean gtk_notebook_reorder_tab         (GtkNotebook      *notebook,
                                                  GtkDirectionType  direction_type,
                                                  gboolean          move_to_last);
+static void     gtk_notebook_remove_tab_label    (GtkNotebook      *notebook,
+                                                 GtkNotebookPage  *page);
 
 /*** GtkObject Methods ***/
 static void gtk_notebook_destroy             (GtkObject        *object);
@@ -1453,7 +1455,8 @@ gtk_notebook_destroy (GtkObject *object)
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (object);
   GtkNotebookPrivate *priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
-  
+  GList *l;
+
   if (notebook->menu)
     gtk_notebook_popup_disable (notebook);
 
@@ -1469,6 +1472,23 @@ gtk_notebook_destroy (GtkObject *object)
       priv->switch_tab_timer = 0;
     }
 
+  for (l = notebook->children; l; l = l->next)
+    {
+      GtkNotebookPage *page = l->data;
+      GtkWidget *w = page->tab_label;
+      if (w) {
+       g_object_ref (w);
+       gtk_notebook_remove_tab_label (notebook, page);
+       gtk_widget_destroy (w);
+       g_object_unref (w);
+      }
+    }
+  /*
+   * Prevent gtk_notebook_update_labels from doing work.  (And from crashing
+   * since we have NULL tab_labels all over.
+   */
+  notebook->show_tabs = FALSE;
+
   GTK_OBJECT_CLASS (gtk_notebook_parent_class)->destroy (object);
 }
 
@@ -4380,6 +4400,9 @@ gtk_notebook_update_labels (GtkNotebook *notebook)
   gchar string[32];
   gint page_num = 1;
 
+  if (!notebook->show_tabs && !notebook->menu)
+    return;
+
   for (list = gtk_notebook_search_page (notebook, NULL, STEP_NEXT, FALSE);
        list;
        list = gtk_notebook_search_page (notebook, list, STEP_NEXT, FALSE))