Re: 2.x API and GDateTime



On Sun, 2012-12-16 at 10:35 +0100, Roland Peffer wrote:
> If I set or get a GDateTime object to/from a grl_media object e.g.
> grl_media_set_creation_date / grl_media_get_creation_date,
> 
> then I suspect that the GDateTime reference counters are untouched?

Not exactly. If you have you own the datetime (so refcount=1), and you
call grl_media_set_creation_date(), Grilo will increase the refcount as
a way of saying "I'm an owner too". 

So after returning refcount is increased in 1.

> 
> What means if I store a GDateTime with grl_media_set_creation_date I
> must not call g_date_time_unref after?


You should call it, or you will have  leak. The function increases the
refcount to have a reference.

GDateTime *d = g_date_time_new_now_utc();
//d->refcount == 1

grl_media_set_creation_date (media, d);
//d->refcount == 2

> And also if I get a GDateTime pointer from grl_media_get_creation_date
> the ref counter is  also not increased.?

Yes.

Following the above example:

GDateTime *new_d = grl_media_get_creation_date (media);
//new_d->refcount == d->refcount == 2


Cheers,

	J.A.




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