Re: Release memory for a GtkWindow



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



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