Re: g_free() vs gtk_widget_destroy()



also emits a "destroy" that is meant to any reference
holders to a to drop the reference it's holding.

I don't think to understand this... :(
Can you tell me more about this?

when you call g_object_unref(G_OBJECT(widget));
your calling a member of the GObjectClass structure.
The GObject has a reference count and when its down
to "0" the GObject will call its "finalize" method.
in affect ... the GtkWidgetClass will override that
method (in the case of a GtkWidget or derivitive) and
call the original after its work (freeing anything a GtkWidget
has to free and emiting the "finalize"
signal on itself).

And another one: if I have a container with a widget into it, before destroy
the container should I destroy the contained widget or it is destroyed automatically?

the container widget will "unreference" all the widgets it contains. if
you dont want it to be destroyed:

g_object_ref...
gtk_container_add...

and then when the container is destroyed you still
have a reference to your widget.


Cheers,
                -Tristan

znt fabio virgilio it wrote:

From: Jeff Franks <jcf tpg com au>

g_free() frees raw memory allocated with g_new().

Ah! So I should never use g_free() g_new() in normal context, right?

gtk_widget_destroy()
marks a widget for destruction when its reference count
reaches zero. It

mmm... so I call gtk_widget_destroy() and GTK internally take trace of all
references to it, so when there is no more references GTK destroy it, right?

also emits a "destroy" that is meant to any reference
holders to a to drop the reference it's holding.

I don't think to understand this... :(
Can you tell me more about this?

And another one: if I have a container with a widget into it, before destroy
the container should I destroy the contained widget or it is destroyed automatically?

Thanks again!

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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