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 728452 - gtk_tree_view_column_create_button creates button which is leaked
gtk_tree_view_column_create_button creates button which is leaked
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
Depends on:
Blocks:
 
 
Reported: 2014-04-17 17:58 UTC by Morten Welinder
Modified: 2017-10-06 23:49 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Morten Welinder 2014-04-17 17:58:57 UTC
The button created in gtk_tree_view_column_create_button is never
destroyed (in the gtk_widget_destroy sense) and never diposed of.

I added

  g_printerr ("Create button %p for column %p\n", priv->button, tree_column);
  g_signal_connect (priv->button, "destroy", cb_button_destroyed, NULL);
  g_object_set_data_full (priv->button, "::leak-check::", priv->button, (GDestroyNotify)cb_button_disposed);

and the functions

static void
cb_button_disposed (GtkWidget *button)
{
	g_printerr ("Button %p disposed\n", button);
}

static void
cb_button_destroyed (GtkWidget *button)
{
	g_printerr ("Button %p destroyed\n", button);
}


Running something that uses a treeview I get...

welinder@sherwood:~/gnome-src/gtk+/gtk> ../tests/testtreeview 
Gtk-Message: Failed to load module "canberra-gtk-module"
Running automated tests...
Passed.
Create button 0x20921a0 for column 0x20910b0
Create button 0x2092320 for column 0x2091180
Create button 0x20924a0 for column 0x2091250
Create button 0x2092620 for column 0x2091320
Create button 0x20927a0 for column 0x20913f0
Create button 0x2092920 for column 0x20914c0
welinder@sherwood:~/gnome-src/gtk+/gtk> 

So not destroyed and not disposed.

The button is made an internal child of the treeview, so it is not subject
to container's recursive destroy.  And nothing else seems to do it.

Adding this line to gtk_tree_view_remove_column:

    gtk_widget_destroy (gtk_tree_view_column_get_button (column));

brings me further:

welinder@sherwood:~/gnome-src/gtk+/gtk> ../tests/testtreeview 
Gtk-Message: Failed to load module "canberra-gtk-module"
Running automated tests...
Passed.
Create button 0xf491a0 for column 0xf478b0
Create button 0xf49320 for column 0xf47980
Create button 0xf494a0 for column 0xf47a50
Create button 0xf49620 for column 0xf47b20
Create button 0xf497a0 for column 0xf47bf0
Create button 0xf49920 for column 0xf47cc0
Button 0xf49920 destroyed
Button 0xf491a0 destroyed
Button 0xf49320 destroyed
Button 0xf494a0 destroyed
Button 0xf49620 destroyed
Button 0xf497a0 destroyed
welinder@sherwood:~/gnome-src/gtk+/gtk> 

Destroyed, but still not disposed.  And I am not sure that fix is right.

This is with 3.10.4, but I am not setup to compile anything significantly
newer.  The leak is not new.
Comment 2 Morten Welinder 2014-04-18 16:54:22 UTC
That patch does indeed help a lot, but it is not a full fix: there still
isn't anything that triggers the gtk_widget_destroy on the button other
than its losing its last ref.

When someone else holds a ref to the button it still never gets destroyed
and the reffer thus never gets told to release the ref.
Comment 3 Daniel Boles 2017-10-06 23:49:14 UTC
Your example now properly disposes the buttons with the fix found incidentally at https://bugzilla.gnome.org/show_bug.cgi?id=788614#c4

If you find any other instances where the buttons are still leaked, please do reopen!