Re: GNOME CVS: libbonobo michael



Hi Jacob,

On 31 Oct 2001, jacob berkman wrote:
> and this doesn't make BonoboObject and GObject behave differently wrt
> ref/unref of NULL objects (which i really this is a horrible idea,
> hence my replying to the commit).

        I'm not sure I understand the reasons behind your problem with
that - if you wish to do:

typedef JACOB_UNREF(o) \
        if (o != NULL) \
                bonobo_object_unref (o); \
        else \
                g_warning ("Something horrifying happened");

        Then go for it; I don't believe it actualy adds any value to
anything. If you're particularly worried about a method being passed NULL
values when it shouldn't be, then pre-conditions are the right solution.

        I imagine in the absence of a pre-condition it is sensible to
assume that a value can be NULL. Oh ... and since the unref returns NULL
you can also do ( in your dispose [1] ):

        a->priv->obj = bonobo_object_unref (a->priv->obj);

        instead of:

        if (a->priv->obj) {
                bonobo_object_unref (a->priv->obj);
                a->priv->obj = NULL;
        }

        or whatever else contorted flow you like ;-) really it's just an
analogue of the equivalent for CORBA_OBJECT_NIL in
bonobo_object_release_unref etc. that has saved many loc & potential bugs.

        Regards,

                Michael.

[1] - which will be called multiple times.

-- 
 mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot




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