Re: [BRANCHES] Giving some sanity to dates



Couple of comments:

In grl-media.c, grl_media_get_publication_date():

**
 * grl_media_get_publication_date:
 * @media: the media object
 *
 * Returns: (transfer full): the media's date (TBD)
 *
 * Since: 0.1.4
 */


It should tell

* Returns: (transfer full): the publication date of @media



In grl-media.c, grl_media_get_publication_date():

GDateTime *
grl_media_get_publication_date (GrlMedia *media)
{
  GDateTime *date;
  date = grl_data_get_boxed (GRL_DATA (media),
                             GRL_METADATA_KEY_PUBLICATION_DATE);
  if (date)
    return g_date_time_ref (date);
  return NULL;
}


Is there any reason to return date as reffed? The same happen in
grl_media_get_modification_date().

My opinion is that we shouldn't return it reffed, and let users to do a
ref() if they want to keep it.

The rationale is that all grl_media_get_foo() functions are always
returning constant information that is owned by GrlMedia. And in all
cases, specially when you handle strings, you know that you need to make
a copy of data if you want to keep it.

So in order to keep it coherent, and not introduce doubts in usesr when
dealing with the returned data ("must I free the returned value?", "do i
need to ref it or not?", ...) , my proposal is to return the GDateTime
without reffing it, and writing (of course) in the doc that the value is
owned by GrlMedia and user should ref() it if they want to keep it.

	J.A.




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