Re: deleting derived widget?



On Saturday 18 February 2006 00:57, Tim Mayberry wrote:
> On Fri, 2006-02-17 at 23:19 +0100, klaus triendl wrote:
> > hi,
> >
> > I'm using derived widgets in my application and I was wondering whether
> > I have to delete them on my own (or let the container widget manage()
> > them) or glademm takes care about them.
> >
> > I've taken a look at the "derived" example of the libglademm source code
> > and the widget is not deleted either. But if the widget is constructed
> > then I guess that it should be also destructed? Just wondering because
> > the destructor gets never called.
>
> Hi Klaus,
>
> It just so happens I was reading this page yesterday
> http://live.gnome.org/LibgladeWithGobjects that has some information
> relating to this.
>
> "Currently, libglade does not claim ownership of any of the objects it
> constructs. It keeps track of them in an internal dictionary, but these
> are weak references that are broken when the constructed object is
> destroyed. While this sounds like it would leak memory, in practice it
> works quite well.
>
> Due to the way GtkObject floating references are handled, each object
> libglade constructs should end up with its one reference being held by
> its container parent. When the top level GtkWindows get destroyed, all
> sub-widgets get destroyed too. So as long as all toplevel windows
> constructed by libglade get destroyed, you won't get any memory leaks."
>
> Hope it is accurate and helps.

gtkmm's memory management is not the same as GTK+'s.  In gtkmm, generally you 
have to call manage() on the widget for it to be owned by its container.  
Whether that also applies to glademm I do not know.

Chris




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