Re: Gtk window.show() (maybe just c++ related)



Thank you, the assumptions you made are right. Another newbie question:
Should I call delete() on each widget created with new() inside this
widget1, or will widget1 do it itself when it will die?
Sorry for such a lame understanding of c++ :-)

Do you know about gtkmm tutorial?
It has a chapter about memory management.
You can call delete for every widget manually, or you may use gtkmm means for memory management.
Which approach to use is up to you to decide.

The following is the text from tutorial:

gtkmm provides the manage() and add() methods to create and destroy widgets. Every widget except a top-level window must be added or packed into a container in order to be displayed. The manage() function marks a packed widget so that when the widget is added to a container, the container becomes responsible for deleting the widget.

MyWidget::MyWidget()
{
Gtk::Button* pButton = manage(new Gtk::Button("Test"));
add(*pButton); //add aButton to MyWidget
}

Now, when MyWidget is destroyed, the button will also be deleted. It is no longer necessary to delete pButton to free the button's memory; its deletion has been delegated to MyWidget.




--
WBR, Pavlo Korzhyk
ICQ#155870780

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