[gjs] object: Correct assertion about toggle up/down on unref



commit b5323962b67bd500b1662ec37b662f3a98a64ede
Author: Colin Walters <walters verbum org>
Date:   Mon Feb 10 01:45:05 2014 -0500

    object: Correct assertion about toggle up/down on unref
    
    It's normal and possible for there to be *both* a TOGGLE_UP and a
    TOGGLE_DOWN queued.  In that case, they would cancel, and we'd be in a
    correct state.
    
    This was consistently triggering in the ostree gjs-based
    test-sysroot.js.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724060

 gi/object.cpp |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index e9f59b3..93a0ad6 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1355,6 +1355,9 @@ object_instance_finalize(JSFreeOp  *fop,
                                     priv->info ? g_base_info_get_name((GIBaseInfo*) priv->info) : 
g_type_name(priv->gtype)));
 
     if (priv->gobj) {
+        gboolean had_toggle_up;
+        gboolean had_toggle_down;
+
         invalidate_all_signals (priv);
 
         if (G_UNLIKELY (priv->gobj->ref_count <= 0)) {
@@ -1363,9 +1366,10 @@ object_instance_finalize(JSFreeOp  *fop,
                     priv->info ? g_base_info_get_name((GIBaseInfo*) priv->info) : g_type_name(priv->gtype));
         }
 
-        cancel_toggle_idle(priv->gobj, TOGGLE_UP);
+        had_toggle_up = cancel_toggle_idle(priv->gobj, TOGGLE_UP);
+        had_toggle_down = cancel_toggle_idle(priv->gobj, TOGGLE_DOWN);
 
-        if (G_UNLIKELY (cancel_toggle_idle(priv->gobj, TOGGLE_DOWN))) {
+        if (!had_toggle_up && had_toggle_down) {
             g_error("Finalizing proxy for an object that's scheduled to be unrooted: %s.%s\n",
                     priv->info ? g_base_info_get_namespace((GIBaseInfo*) priv->info) : "",
                     priv->info ? g_base_info_get_name((GIBaseInfo*) priv->info) : g_type_name(priv->gtype));


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