LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Can gtk free widget ? (http://www.linuxquestions.org/questions/programming-9/can-gtk-free-widget-827105/)

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:

Code:

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.

Code:

gtk_widget_destroy(button);
the code above will only destroy the last button which it has a reference to.


All times are GMT -5. The time now is 09:39 PM.