Re: gtk_pixmap_get() doesn't ref the out parameters.



On Sun, 2001-10-21 at 03:49, Owen Taylor wrote:
> 
> murrayc t-online de (Murray Cumming) writes:
> 
> > gtk_pixmap_get just returns pointers to GdkPixmap and GdkBitmap struct
> > members. Shouldn't it ref them before doing so?
> > 
> > Or have I misunderstood the refcounting policy. 
> 
> The policy is:
> 
>  - Newly created objects return a refcount to the caller
>  - Otherwise, returned (and out) objects do not get a new 
>    refcount, the caller has to ref them if a persistant
>    copy is desired.

And how do I know whether it's newly created? This makes
automatically-generated language binding unpleasant.

> 
> The reasons for this are:
> 
>  - convenience from C
>  - it's easier to catch too few refcounts than too many.
> 
> [ An exception to the above is g_object_get() on a object-valued
>   property - a new refcount will be returned in that case
>   as a consequence of the same general rules that end up
>   with strings and boxed objects copied for g_object_get ]

Are Boxed Type objects ever returned without a copy, like newly-created
objects?

> > Is there a statement of the policy somewhere?
> 
> Well, aside from the above (and similar), not that I know of.

Thanks. It seems important.

-- 
Murray Cumming
murrayc usa net
www.murrayc.com




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