Avoid g_object_ref/unref in some cases

We only need to take a ref on the object when
we call out to external code (ie around
->dispatch_properties_changed). If we avoid
the signal emission, we can avoid the ref/unref
too.
This commit is contained in:
Matthias Clasen 2022-05-17 07:11:19 -04:00
parent bbd170a223
commit 422bd8e966

View File

@ -1358,9 +1358,15 @@ g_object_notify_by_spec_internal (GObject *object,
g_object_notify_queue_thaw (object, nqueue);
}
else
{
g_object_ref (object);
/* not frozen, so just dispatch the notification directly */
G_OBJECT_GET_CLASS (object)
->dispatch_properties_changed (object, 1, &pspec);
g_object_unref (object);
}
}
}
@ -1391,7 +1397,6 @@ g_object_notify (GObject *object,
if (g_atomic_int_get (&object->ref_count) == 0)
return;
g_object_ref (object);
/* We don't need to get the redirect target
* (by, e.g. calling g_object_class_find_property())
* because g_object_notify_queue_add() does that
@ -1408,7 +1413,6 @@ g_object_notify (GObject *object,
property_name);
else
g_object_notify_by_spec_internal (object, pspec);
g_object_unref (object);
}
/**
@ -1467,9 +1471,7 @@ g_object_notify_by_pspec (GObject *object,
if (g_atomic_int_get (&object->ref_count) == 0)
return;
g_object_ref (object);
g_object_notify_by_spec_internal (object, pspec);
g_object_unref (object);
}
/**