[gjs] Error more verbosely when we finalize a proxy for a dead object



commit 1deced809e3f09f9b787dd07dfd7558dc46f7461
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Nov 15 15:01:23 2010 -0500

    Error more verbosely when we finalize a proxy for a dead object
    
    Include information about the type of the affected object when
    there was a reference counting error that resulted in a proxy
    pointing to a GObject that has already been finalized.

 gi/object.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/gi/object.c b/gi/object.c
index 882cfe9..ffa4fa6 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -795,7 +795,11 @@ object_instance_finalize(JSContext *context,
                                     g_base_info_get_name ( (GIBaseInfo*) priv->info) ));
 
     if (priv->gobj) {
-        g_assert(priv->gobj->ref_count > 0);
+        if (G_UNLIKELY (priv->gobj->ref_count <= 0)) {
+            g_error("Finalizing proxy for an already freed object of type: %s.%s\n",
+                    g_base_info_get_namespace((GIBaseInfo*) priv->info),
+                    g_base_info_get_name((GIBaseInfo*) priv->info));
+        }
         set_js_obj(context, priv->gobj, NULL);
         g_object_remove_toggle_ref(priv->gobj, wrapped_gobj_toggle_notify,
                                    JS_GetRuntime(context));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]