GNOME Bugzilla – Bug 388321
gtk_notebook_remove_tab_label
Last modified: 2008-05-30 18:35:36 UTC
If something holds a ref to my tab widget, it does not seem to get destroyed. If the ref is due to a grab, see bug 388043, gtk enters a pretty bad state. gtk_notebook_remove_tab_label simply unparents. gtk_notebook_destroy only destroys pages.
Can we get this on the radar, please? This feels like a small fix.
Created attachment 99147 [details] [review] Patch to fix life cycle of tab labels
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)
*** Bug 500049 has been marked as a duplicate of this bug. ***
This change broke epiphany: it crashes when closing a window, see bug 500049. The problem is that epiphany's GtkNotebook's GtkContainer::remove implementation accesses the tab's tab label before calling the parent's ::remove implementation, and with this change, the tab label is already gone at this time.
Hmm... Sorry about that. I am open for other strategies for destroying the labels, but destroyed they should be. It seems to me that you are depending on what order children of the notebook happens to be destroyed. Any chance you could hold a ref?
*** Bug 500415 has been marked as a duplicate of this bug. ***
I think that prior to calling GtkNotebook's GtkContainer::remove implementation, the tab can be deemed to be in the container, and have its tab label intact; I shouldn't have to do anything like keeping a ref to it myself. The patch broke epiphany; I think it needs to be reverted. As for a proper fix, why not destroy the tab label in ::remove ?
Created attachment 100194 [details] [review] another attempt
Actually the fix broke evince: (evince:2447): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed (evince:2447): Gtk-CRITICAL **: gtk_widget_destroy: assertion `GTK_IS_WIDGET (widget)' failed (evince:2447): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed It appears that |tab_label| is NULL.
Matthias: notebook->show_tabs = FALSE; is probably useful in any case.
Christian: more info, please. Stack trace for first critical, for example. What did you do at the time?
Step to repro: 0) $ evince some.pdf 1) Close window Trace from 1st warning:
+ Trace 180882
That means that in this code: + tab_label = page->tab_label; + g_object_ref (tab_label); gtk_notebook_remove_tab_label (notebook, page); + if (destroying) + gtk_widget_destroy (tab_label); + g_object_unref (tab_label); the tab_label is NULL.
Try the obvious ifs: + tab_label = page->tab_label; + if (tab_label) + g_object_ref (tab_label); gtk_notebook_remove_tab_label (notebook, page); + if (tab_label) + { + if (destroying) + gtk_widget_destroy (tab_label); + g_object_unref (tab_label); + }
*** Bug 501929 has been marked as a duplicate of this bug. ***
*** Bug 501870 has been marked as a duplicate of this bug. ***
Created attachment 100378 [details] [review] fix the fix fixing the fix for the bug This fixes the problem in evince.
2007-12-10 Matthias Clasen <mclasen@redhat.com> * gtk/gtknotebook.c (gtk_notebook_real_remove): Another fix to avoid further fallout from the fix for bug 388321.
*** Bug 503625 has been marked as a duplicate of this bug. ***
*** Bug 510433 has been marked as a duplicate of this bug. ***