-   Programming (
-   -   Can gtk free widget ? (

915086731 08-18-2010 08:52 PM

Can gtk free widget ?
Hello everyone!

I am confused that after I call gtk_button_new() many times, how can I free these buttons. Let's see the following codes:


Gtkwidget *button;
button = gtk_button_new();  //the first call
button = gtk_button_new();  //the second call
button = gtk_button_new();  // the third call

The gtk_button_new() was called three times, and I think memory is eaten by every call, how can I release the memory used by the first and second calls.
Do other gtk Widgets work similar to button ?

joel2001k 08-19-2010 10:46 AM

RE: Can gtk free widget ? Reply to Thread
You may use gtk_widget_destroy which should destroy all child widgets, too. Pack it in a container or save a pointer to the widgets eg. in a GList, that you can free it's memory.


the code above will only destroy the last button which it has a reference to.

All times are GMT -5. The time now is 07:19 PM.