[glib: 1/2] gobject: Convert a debug check from an assertion to a g_critical()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gobject: Convert a debug check from an assertion to a g_critical()
- Date: Wed, 10 Oct 2018 23:36:37 +0000 (UTC)
commit b9a8c039158caadbde7335f706fecdc56a90f96b
Author: Philip Withnall <withnall endlessm com>
Date: Wed Oct 10 10:21:49 2018 +1300
gobject: Convert a debug check from an assertion to a g_critical()
An assertion is harder to skip over, and using a g_critical() can give
us a more informative error message.
Signed-off-by: Philip Withnall <withnall endlessm com>
https://gitlab.gnome.org/GNOME/glib/issues/179
gobject/gobject.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index f82fa8c79..3f8ad9273 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -3349,10 +3349,16 @@ g_object_unref (gpointer _object)
GOBJECT_IF_DEBUG (OBJECTS,
{
- /* catch objects not chaining finalize handlers */
- G_LOCK (debug_objects);
- g_assert (!g_hash_table_contains (debug_objects_ht, object));
- G_UNLOCK (debug_objects);
+ gboolean was_present;
+
+ /* catch objects not chaining finalize handlers */
+ G_LOCK (debug_objects);
+ was_present = g_hash_table_remove (debug_objects_ht, object);
+ G_UNLOCK (debug_objects);
+
+ if (was_present)
+ g_critical ("Object %p of type %s not finalized correctly.",
+ object, G_OBJECT_TYPE_NAME (object));
});
g_type_free_instance ((GTypeInstance*) object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]