Re: Good style for memory management?



Roland Schwarz wrote:
> Paul Pogonyshev wrote:
> > When I used gtkmm, I tended to let GTK+ manage all widgets itself, i.e.
> > by calling manage() on them.  This way, widgets in destroyed containers
> > are normally destroyed as well and you don't need to keep references to
> > them.  You only need to delete windows.
> 
> Ok, fine. But how to you handle the time between new'ing the widgets and
> adding them to their container? If I understand the memory management
> correctly the widgets are effectively unmanaged until they have been
> added to the container. I.e. if something throws before they have been
> added to the container, none will clean up (manage) them. Not?

Gtk::VBox*  vbox = manage (new Gtk::VBox (...));

Something like that.  Nothing can throw in between.  In any case, you can
not care about memory leaks if something throws when you build your GUI.
Because then you have more important problems at hands, right?

Paul



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