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 775212 - GtkScaleButton does not unref all GtkAdjustment it references
GtkScaleButton does not unref all GtkAdjustment it references
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-11-28 09:33 UTC by Massimo
Modified: 2016-11-28 20:07 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Massimo 2016-11-28 09:33:28 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[])     
{
  if (gtk_init_check (&argc, &argv))
    {
      int i;

      for (i = 0; i < ITERATIONS; ++i)
        {
          GtkWidget *win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
          GtkWidget *vol = gtk_volume_button_new ();

          gtk_container_add (GTK_CONTAINER (win), vol);
          gtk_widget_show_all (win);
          gtk_widget_destroy (win);
        }
    }

  return 0;
}
      

the number of objects alive at exit increases for the presence
of a GtkAdjustment.
      
The problem is that GtkScaleButton tries to manage (set/get) an adjustment
that is declared in a ui file as a template child. 
The reference added in init:

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

would be balanced in finalize by this unref:

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

but because priv->adjustment is registered as the automated child pointer

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

it gets NULL-ed during GObjectClass.dispose() and so the unref is skipped.

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-class-bind-template-child-full