On Fri, 2009-02-27 at 11:56 +0100, Michal Kolodziejczyk wrote:
> Emmanuele Bassi wrote:
> 
> > the window for changing this, though, is closing fast. I'll wait until
> > next week to do the change.
> 
> So I have another question regarding the reference counting in API
> functions. Here is what Wolfgang wrote:
> 
> "A more serious problem with the API is that at least the function
> clutter_container_add_actor, but probably many other functions too,
> keep a pointer to an object without increasing the reference count;

this is utterly wrong on at least two counts:

  - clutter_container_add_actor() is a function calling the
    ClutterContainer interface implementations. it doesn't have
    anything to deal with reference counting because that's
    what a Container implementation has to do

  - if a Container implementation does not call:

      clutter_actor_set_parent()

    on the newly added children then it is completely broken

  - the clutter_actor_set_parent() function will sink the floating
    reference and take a reference on the actor

I repeat: clutter_container_add_actor() doesn't do anything more than
retrieving the ClutterContainer vtable from an actor (if present) and
call the ::add() function pointer. calling clutter_actor_set_parent() is
demanded to the Container implementation.

> the caller must "know" that and either increase the refcount, or
> simply discard the pointer.  This may be an optimization but is
> inconvenient, and hasn't changed in 0.9."

the caller doesn't have to do anything of sort. it's not an
optimization, and it's not "inconvenient". the only inconvenience you or
Wolfgang are experimenting is not having read the documentation that
clearly states in at least two different places what a ClutterContainer
implementation must do in order to be correct.

ciao,
 Emmanuele.

-- 
Emmanuele Bassi, Intel Open Source Technology Center

-- 
To unsubscribe send a mail to [email protected]

Reply via email to