bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnubg] Memory leaks


From: Nardy Pillards
Subject: [Bug-gnubg] Memory leaks
Date: Thu, 2 Jan 2003 00:07:32 +0100

This is about memory leaks and GTK

http://www.moongroup.com/pipermail/xfce4-dev/2002-November/000900.html

"gtk_widget_destroy() doesn't do memory management"

"
... when you call gtk_button_new() nobody owns the button
until someone "adopts" the initial reference, so nobody
is going to drop the reference in response to destroy().

Generally, if you want to have a widget that you may or 
not add to a parent, the thing to do is:

When you create the widget:

 b = gtk_button_new ();
 /* Adopt the initial reference */
 g_object_ref (G_OBJECT (b));
 gtk_object_sink (GTK_OBJECT (b));

When you want to get rid of the widget:

 /* Tell other people to drop their references */
 gtk_object_destroy (GTK_OBJECT (b));
 /* Drop your own reference */;
 g_object_unref (GTK_OBJECT (b));
"
__________
Nardy 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]