On Sun, 28 Jun 2009 21:01:18 -0600
Michael Torrie <[email protected]> wrote:
> [email protected] wrote:
> > GtkWidget *widget; 
> > 
> > widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); 
> 
> This is the way you have to do it.  As the function name implies, this
> allocates a new window.  If you want to get rid of it, you have to
> unref it which, when the ref count drops to zero, will cause it to be
> freed. If you don't you'll have a memory like.  This is pretty
> standard in C. Of course sometimes an API call gives you a pointer
> (reference to an object) but you don't need to free it when you're
> done because someone else will.

This is true as an overview of how it works, but you shouldn't call
g_object_unref() on a GtkWindow object to get rid of it.  You should
call gtk_object_destroy() or gtk_widget_destroy() on it, which will (by
emitting the destroy signal) cause amongst other things GTK+ to drop its
reference to the window. It will also cause GTK+ to do other clean-up,
such as taking it out of the list of top level windows.

Chris

_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to