ObjectWrap.stealQdata
void * stealQdata(glib.types.Quark quark)This function gets back user data pointers stored via [gobject.object.ObjectWrap.setQdata] and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:
void
object_add_to_user_list (GObject *object,
const gchar *new_string)
{
// the quark, naming the object data
GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
// retrieve the old string list
GList *list = g_object_steal_qdata (object, quark_string_list);
// prepend new string
list = g_list_prepend (list, g_strdup (new_string));
// this changed 'list', so we need to set it again
g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
}
static void
free_string_list (gpointer data)
{
GList *node, *list = data;
for (node = list; node; node = node->next)
g_free (node->data);
g_list_free (list);
} Using [gobject.object.ObjectWrap.getQdata] in the above example, instead of [gobject.object.ObjectWrap.stealQdata] would have left the destroy function set, and thus the partial string list would have been freed upon [gobject.object.ObjectWrap.setQdataFull].Parameters
quark | A #GQuark, naming the user data pointer |
Returns
The user data pointer set, or null