Re: deleting derived widget?



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.

Somewhat related is this bug:
http://bugzilla.gnome.org/show_bug.cgi?id=134161 which proposes an
alternate interface to the derived widget which looks preferable to the
current form.

Tim.




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