Re: Wrapping C constructors.

On Mon, 2007-05-21 at 05:21 -0500, Paul Davis wrote:
> On 5/21/07, Murray Cumming <murrayc murrayc com> wrote:

> > > Each goocanvas object is added automatically to its parent
> > > object. Adding an object to a parent object causes the ref_count to be
> > > incremented (making the ref_count = 2 ) then the new() function unrefs
> > > it (making it 1 again).
> >
> > OK. That is quite unusual, and seems like a bug in goocanvas to me,
> > because its inconsistent with other GTK+ functions. A _new() function
> > usually returns a reference and requires a g_object_unref() later.
> > GtkWidgets don't, but they use their own "floating" reference idea.
> >
> I'm not sure I'd call this a bug, rather, it just doesn't behave in
> the standard gtk way.
> > After checking that this is really what goocanvas wants to do, you might
> > need to add the reference, as you suggest.
> >
> This is how all of the goocanvas demo code works. I'm 99% sure this is
> the correct reasoning, but I'll post a message to the goocanvas list
> to double check.

this is also how the GnomeCanvas works - the canvas takes ownership of
objects automatically, unlike GTK containers. i don't think its an error
- its actually one of the little details i rather like about canvas
programming. its very rare that i want a canvas item to have a lifetime
of its own, and unlike at the widget level, i don't even have to use
manage() to achieve this.


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