GObject.Object.steal_qdata

### Method

# GObject Objectsteal_qdata

#### Declaration

    gpointer
    g_object_steal_qdata (
      GObject* object,
      GQuark quark
    )

#### Description

This function gets back user data pointers stored via `g_object_set_qdata()` 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 `g_object_get_qdata()` in the above example, instead of `g_object_steal_qdata()` would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().

#### Parameters

`quark`

  Type: `GQuark`

  A `GQuark`, naming the user data pointer.

#### Return value

Type: `gpointer`

The user data pointer set, or `NULL`.

The caller of the method takes ownership of the data, and is responsible for freeing it.
The return value can be `NULL`.