Re: ref-counting issue ...



on 4/24/01 2:59 PM, Michael Meeks at michael ximian com wrote:

> So, I plan to commit the above shortly, unless anyone screams.
> I see no reason why they should - but ref counting is always tricky,
> and I've probably lost it, again. Either way, the fix makes me pretty
> queasy just looking at it - yet another argument for tighter component
> / orb integration.

This sounds like the wrong solution to me. In my opinion, you should not
commit this change.

> Needs to destroy the associated CORBA resources,
> 
>     BonoboObject *o = create_object ();
>     bonobo_object_release_unref (BONOBO_OBJREF (o), NULL);

This should be an illegal code sequence. When you call BONOBO_OBJREF you get
an object reference that you don't own. You can't just release and unref it.

You should show me places where this idiom is used, and I'll show you nice
ways to fix it so it doesn't need to do things this way.

Here's the legal version:

    BonoboObject *o = create_object ();
    Bonobo_Unknown r = bonobo_object_dup_ref (BONOBO_OBJREF (o), NULL);
    bonobo_object_unref (o);

    /* do lots of stuff here */

    bonobo_object_release_unref (r, NULL);

I see no problem in changing places that erroneously do the above to do
things more like what we see here.

Your thoughts, Michael?

    -- Darin





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