Re: Release memory for a GtkWindow



On Thu, Mar 14, 2002 at 08:50:04AM -0500, Havoc Pennington wrote:
mrl netbank com br writes:
In this case would be better you call 2 times gtk_widget_unref(window)
becose when you create it, it has ref count at 1, you referenced it, so it's
at 2, and then you wanna delete, so 2 - 1 = 1   1 - 1 = 0, it's 2 times you
have to call, becose you didn't release the reference of the builder
function.

No! That isn't correct. When you create a window it has a ref count of
1, but that count is owned by GTK. You can't call unref(), you must
call gtk_object_destroy(), which will cause GTK to drop its count. If
you can unref() then GTK will segfault eventually.

In the example code I think gtk_object_destroy() on the window will
free everything, though I don't understand why the extra ref on the
child button is used, since containers ref their children anyway.

Havoc
---end quoted text---

Oops! sorry.. hehe :)
I thought it was just referenced to optimize the creations, then you wouldn't
need to call gtk_widget_ref(..) again..

BTW, calling gtk_object_destroy() will destroy the widget, even if it has
refcount = 2, 3, ... or it will just return?

[]'s
-- 
Marcelo R Leitner <mrl netbank com br>
ICQ #: 29966851



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