/* It is important that your #GValue holds a reference to @v_object (either its own, or one it has taken) to ensure that the object won't be destroyed while the #GValue still exists).  */
void g_value_set_object(GValue *value, gpointer v_object)
/* It is important that your #GValue holds a reference to @v_object (either its own, or one it has taken) to ensure that the object won't be destroyed while the #GValue still exists).  */
void g_value_set_object(GValue *value, gpointer v_object)
{
  GObject *old;
  g_return_if_fail (G_VALUE_HOLDS_OBJECT (value));
  old = value->data[0].v_pointer;
  if (v_object)
    {
      g_return_if_fail (G_IS_OBJECT (v_object));
      g_return_if_fail (g_value_type_compatible (G_OBJECT_TYPE (v_object), G_VALUE_TYPE (value)));
      value->data[0].v_pointer = v_object;
      g_object_ref (value->data[0].v_pointer);
    }
  else
    value->data[0].v_pointer = NULL;
  if (old)
    g_object_unref (old);
}