Order refs/unrefs so setting the same object back is safe. (#112861,

Fri May 30 14:42:24 2003  Owen Taylor  <otaylor@redhat.com>

        * gobject.c (g_value_set_object): Order refs/unrefs
        so setting the same object back is safe. (#112861,
        Morten Welinder)
This commit is contained in:
Owen Taylor 2003-05-30 18:44:57 +00:00 committed by Owen Taylor
parent 614e5ed63a
commit 68e49c7811
2 changed files with 15 additions and 6 deletions

View File

@ -1,3 +1,9 @@
Fri May 30 14:42:24 2003 Owen Taylor <otaylor@redhat.com>
* gobject.c (g_value_set_object): Order refs/unrefs
so setting the same object back is safe. (#112861,
Morten Welinder)
2003-03-24 Sven Neumann <sven@gimp.org>
* gtype.c (type_data_finalize_class_ifaces_Wm): removed leftover

View File

@ -1508,14 +1508,12 @@ void
g_value_set_object (GValue *value,
gpointer v_object)
{
GObject *old;
g_return_if_fail (G_VALUE_HOLDS_OBJECT (value));
if (value->data[0].v_pointer)
{
g_object_unref (value->data[0].v_pointer);
value->data[0].v_pointer = NULL;
}
old = value->data[0].v_pointer;
if (v_object)
{
g_return_if_fail (G_IS_OBJECT (v_object));
@ -1524,6 +1522,11 @@ g_value_set_object (GValue *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);
}
void