From 30e1d69de761d5c63d92718a9704e9e60eba20cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 5 Dec 2022 20:22:11 +0100 Subject: [PATCH] gobject: Check for valid ref counting via g_return_if_fail Even though the check is likely to be relevant if the object is finalized, it may still give some indication if called while an instance has just lost the last reference. So use `g_return_if_fail` for consistency with the rest of the code. --- gobject/gobject.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gobject/gobject.c b/gobject/gobject.c index c1a69a896..788bb0be2 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -1468,9 +1468,7 @@ void g_object_freeze_notify (GObject *object) { g_return_if_fail (G_IS_OBJECT (object)); - - if (g_atomic_int_get (&object->ref_count) == 0) - return; + g_return_if_fail (g_atomic_int_get (&object->ref_count) > 0); g_object_ref (object); g_object_notify_queue_freeze (object, FALSE); @@ -1670,9 +1668,8 @@ g_object_thaw_notify (GObject *object) GObjectNotifyQueue *nqueue; g_return_if_fail (G_IS_OBJECT (object)); - if (g_atomic_int_get (&object->ref_count) == 0) - return; - + g_return_if_fail (g_atomic_int_get (&object->ref_count) > 0); + g_object_ref (object); /* FIXME: Freezing is the only way to get at the notify queue.