LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2010, 07:52 PM   #1
915086731
Member
 
Registered: Apr 2010
Posts: 144
Blog Entries: 6

Rep: Reputation: 2
Lightbulb 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 ?
 
Old 08-19-2010, 09:46 AM   #2
joel2001k
Member
 
Registered: Mar 2007
Distribution: GNU/Linux debian unstable main
Posts: 95

Rep: Reputation: 17
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.

Last edited by joel2001k; 08-19-2010 at 09:50 AM.
 
1 members found this post helpful.
  


Reply

Tags
free, gtk, memory, widget



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Showing a widget above a widget in GTK aarontwc Programming 4 11-26-2008 11:40 AM
How to use the GTK Iconview widget LinuxNoob75 Programming 1 12-29-2007 06:40 PM
GTK widget which to use? cranium2004 Programming 1 02-20-2006 01:29 PM
Which GTK Widget to use? jpbarto Programming 0 11-20-2003 07:34 PM
what is a gtk-widget ? gladeiator Programming 3 10-30-2003 05:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration