[glib: 1/2] gobject: Clarify assertion failure on ref-after-finalize
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gobject: Clarify assertion failure on ref-after-finalize
- Date: Mon, 23 Mar 2020 12:31:04 +0000 (UTC)
commit 641bbd08484f4e67e3b8d3e0843ec70e82277db3
Author: Philip Withnall <withnall endlessm com>
Date: Mon Mar 23 11:48:22 2020 +0000
gobject: Clarify assertion failure on ref-after-finalize
Rename the variables involved so that people get a slightly more
obvious critical warning when they try to ref an object which has
already been finalised.
Signed-off-by: Philip Withnall <withnall endlessm com>
gobject/gobject.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index eea40b3ae..c5b3b83a8 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -3361,11 +3361,13 @@ gpointer
{
GObject *object = _object;
gint old_val;
+ gboolean object_already_finalized;
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
old_val = g_atomic_int_add (&object->ref_count, 1);
- g_return_val_if_fail (old_val > 0, NULL);
+ object_already_finalized = (old_val <= 0);
+ g_return_val_if_fail (!object_already_finalized, NULL);
if (old_val == 1 && OBJECT_HAS_TOGGLE_REF (object))
toggle_refs_notify (object, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]