Re: deprecation of gdk_drawable_xxx



On Thu, 22 Feb 2001, Oskar Liljeblad wrote:

> I'm also curious why there are no
> 
>  g_object_set_data
>  g_object_set_data_full
>  g_object_get_data
>  g_object_remove_data
>  g_object_remove_qdata
>  g_object_steal_data

uhm, havoc recently added:
gpointer    g_object_get_data                 (GObject        *object,
                                               const gchar    *key);
void        g_object_set_data                 (GObject        *object,
                                               const gchar    *key,
                                               gpointer        data);
void        g_object_set_data_full            (GObject        *object,
                                               const gchar    *key,
                                               gpointer        data,
                                               GDestroyNotify  destroy);
gpointer    g_object_steal_data               (GObject        *object,
                                               const gchar    *key);


> I think g_object_remove_data(obj, key) is slightly more readable
> than g_object_set_data(obj, key, NULL). Also, it may be tempting
> to use g_object_steal_qdata instead of g_object_set_data(.., NULL).
> The function g_object_remove_(q)data would overcome this problem.
> (As I understand it, steal_qdata should not be used because
> one is lazy, but because it is necessary to remove the data without
> notification.)

you're right about steal, it's just there if you want to do things
like modifying e.g. a GList that should usually be freed upon finalization.
i'm not really opposed to adding g_object_remove_data(), though i
personally never use it, but set_data(,NULL) instead...

> Another reason for adding g_object_remove_data is for the
> future possibility of allowing NULL data (like the Java
> Collections framework does)... Unfortunately this would require
> the behavior of g_object_set_data to be changed.

that's not really possible, too much code relies on setting NULL
being equivalent to remove.

> 
> Oskar Liljeblad (osk hem passagen se)
> 

---
ciaoTJ





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