Re: 2.x API and GDateTime



Thanks for the answer.
I checked again:

 grl_media_set_creation_date (media);  increases the reference counter.

 grl_media_get_creation_date(media)  leaves reference counter untouched.


For my understanding this is not correct.
Either grl_media_get_creation_date should be marked with const ,
or better also should increase the ref counter on the GDateTime object.


Roland


On 16.12.2012, at 12:24, Juan A. Suarez Romero wrote:

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.


_______________________________________________
grilo-list mailing list
grilo-list gnome org
https://mail.gnome.org/mailman/listinfo/grilo-list



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