After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 774706 - GtkNotebook does not unref all GtkLabel it creates
GtkNotebook does not unref all GtkLabel it creates
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkNotebook
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-11-19 11:13 UTC by Massimo
Modified: 2018-05-02 17:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Massimo 2016-11-19 11:13:47 UTC
After setting GOBJECT_DEBUG=objects comparing the outputs
of the following program run with ITERATIONS set to 2 and 1:

#include <gtk/gtk.h>

#ifndef ITERATIONS
#define ITERATIONS 2
#endif

int
main (int argc,
      char *argv[])
{   
  int i;
  if (gtk_init_check (&argc, &argv))
    for (i = 0; i < ITERATIONS; ++i)
      { 
        GtkWidget *window   = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        GtkWidget *notebook = gtk_notebook_new (); 
        GtkWidget *page     = gtk_drawing_area_new ();

        gtk_container_add (GTK_CONTAINER (window), notebook);
        
        gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE);
        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
      
        gtk_widget_destroy (window);
      }

  return 0;
}


the number of objects alive at exit increases for the presence
of few GtkLabel objects.

The problem is here:

https://git.gnome.org/browse/gtk+/tree/gtk/gtknotebook.c?h=gtk-3-22#n6967


page->tab_label is parented to the notebook which implements GtkContainer::remove
to remove children (pages), but does nothing with tab_label, so it is wrong to
call gtk_widget_destroy here because it does not properly complete the destruction.
Comment 1 Daniel Boles 2017-09-12 20:11:46 UTC
Since you seem very good at finding and analysing issues like this, it'd be great if you could apply that detailed, existing knowledge to writing patches to fix them. :)
Comment 2 GNOME Infrastructure Team 2018-05-02 17:46:41 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/706.