From 325cf071d1b6de55eac2a97d8f38558efda17807 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 23 Jun 2012 09:59:10 -0400 Subject: GtkNotebook: Maintain invariants during tab dnd It turns out that we can end up removing a notebook child while the tab is still 'detached'. Child removal causes gtk_notebook_remove_tab_label() to be called on the tab label, but that function did not deal with the eventuality that the tab label may be a child of the dnd window. http://bugzilla.gnome.org/show_bug.cgi?id=677943 --- gtk/gtknotebook.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'gtk/gtknotebook.c') diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index a7f05d5c7e..214af5668d 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -3150,11 +3150,8 @@ hide_drag_window (GtkNotebook *notebook, { g_object_ref (page->tab_label); - if (GTK_IS_WINDOW (parent)) - { - /* parent widget is the drag window */ - gtk_container_remove (GTK_CONTAINER (parent), page->tab_label); - } + if (GTK_IS_WINDOW (parent)) /* parent widget is the drag window */ + gtk_container_remove (GTK_CONTAINER (parent), page->tab_label); else gtk_widget_unparent (page->tab_label); @@ -4932,7 +4929,17 @@ gtk_notebook_remove_tab_label (GtkNotebook *notebook, page->mnemonic_activate_signal = 0; gtk_widget_set_state_flags (page->tab_label, 0, TRUE); - gtk_widget_unparent (page->tab_label); + if (gtk_widget_get_window (page->tab_label) != gtk_widget_get_window (GTK_WIDGET (notebook)) || + !NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)) + { + GtkWidget *parent; + + parent = gtk_widget_get_parent (page->tab_label); + if (GTK_IS_WINDOW (parent)) + gtk_container_remove (GTK_CONTAINER (parent), page->tab_label); + else + gtk_widget_unparent (page->tab_label); + } page->tab_label = NULL; } } -- cgit v1.2.1