gobject: adjust assertion for ref-count in g_object_freeze_notify()

g_atomic_int_get() returns a signed int. While we don't expect this to be ever
negative, a negative value would also indicate a bug. Adjust the check to assert
against negative ref-count too.
This commit is contained in:
Thomas Haller 2023-12-12 09:19:51 +01:00
parent 30d6e911c4
commit 28331deae2

View File

@ -1433,7 +1433,7 @@ g_object_freeze_notify (GObject *object)
g_return_if_fail (G_IS_OBJECT (object));
#ifndef G_DISABLE_CHECKS
if (G_UNLIKELY (g_atomic_int_get (&object->ref_count) == 0))
if (G_UNLIKELY (g_atomic_int_get (&object->ref_count) <= 0))
{
g_critical ("Attempting to freeze the notification queue for object %s[%p]; "
"Property notification does not work during instance finalization.",
@ -1643,7 +1643,7 @@ g_object_thaw_notify (GObject *object)
g_return_if_fail (G_IS_OBJECT (object));
#ifndef G_DISABLE_CHECKS
if (G_UNLIKELY (g_atomic_int_get (&object->ref_count) == 0))
if (G_UNLIKELY (g_atomic_int_get (&object->ref_count) <= 0))
{
g_critical ("Attempting to thaw the notification queue for object %s[%p]; "
"Property notification does not work during instance finalization.",