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



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.

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 ]

> Is there a statement of the policy somewhere?

Well, aside from the above (and similar), not that I know of.

                                        Owen




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