On Tue, 2011-03-01 at 11:18 +0100, Yann Leydier wrote: > Hi, > > The doc specifies that Gtk::Container::Remove(Gtk::Widget*) does not > frees managed widgets. As the method is called with a parameter it is > not difficult to delete the pointer aftewards. > > With Gtk::Bin::Remove(), there is no parameter. Can I expect the method > to delete the contained widget (given that it is managed),
No, we generally avoid unexpected side-effects like that. You removed it from the container, so it is no longer managed by the container. "manage"d by the container means "deleted when the container is deleted", not "deleted if every removed from the container". > or shall I > delete it myself ? Yes. > If so, how ? With the delete keyword? > solution 1: > Gtk::Widget *content = mybin.get_child(); > mybin.remove(); > delete content; That's fine. Though if you called Gtk::manage() on the widget then you should already know the pointer. It's unwise to just blindly delete any child widget - it might not be the one that you created. > solution 2: > delete mybin.get_child(); // will the bin know that its child does not > exist anymore ? It should, yes, though I would personally not depend on that. > solution 3: > mybin.get_child()->unreference(); // will it delete the widget ? You should never have any need to manually call reference() and unreference(). That will break things. > I'm looking for the cleanest (and if possible shortest) solution. > > Thanks, > yann > _______________________________________________ -- [email protected] www.murrayc.com www.openismus.com _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
