GNOME Bugzilla – Bug 775212
GtkScaleButton does not unref all GtkAdjustment it references
Last modified: 2016-11-28 20:07:00 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