[gjs] object: Don't invalidate closure if already invalid



commit bace908922aa6ee9ee3885eef01b75816ece842f
Author: Philip Chimento <philip endlessm com>
Date:   Mon Jun 19 16:19:07 2017 -0700

    object: Don't invalidate closure if already invalid
    
    In object_instance_finalize() we get two kinds of signal connections:
    ones that are still connected, which we need to invalidate; and ones that
    have just been disconnected and invalidated but whose invalidate idle
    function has not yet run.
    
    The second kind we just need to disconnect the idle handler and free the
    ConnectData. We should not try to remove the invalidate notifier, since
    it has already run. The first kind, we must remove the invalidate
    notifier so that no idle invalidation is scheduled, and then invalidate
    them, and also free the ConnectData.
    
    Previously we were mixing the two and removing notifiers from both kinds.
    This led to warnings about removing uninstalled invalidation notifiers.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783951

 gi/object.cpp |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index e29df47..c98425c 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1440,15 +1440,16 @@ object_instance_finalize(JSFreeOp  *fop,
          */
         for (ConnectData *cd : priv->signals) {
             /* First remove any pending invalidation, we are doing it now. */
-            if (cd->idle_invalidate_id > 0)
+            if (cd->idle_invalidate_id > 0) {
                 g_source_remove(cd->idle_invalidate_id);
+            } else {
+                /* We have to remove the invalidate notifier, which would
+                 * otherwise schedule a new pending invalidation. */
+                g_closure_remove_invalidate_notifier(cd->closure, cd,
+                                                     signal_connection_invalidated);
+                g_closure_invalidate(cd->closure);
+            }
 
-            /* We also have to remove the invalidate notifier, which would
-             * otherwise schedule a new pending invalidation. */
-            g_closure_remove_invalidate_notifier(cd->closure, cd,
-                                                 signal_connection_invalidated);
-
-            g_closure_invalidate(cd->closure);
             g_slice_free(ConnectData, cd);
         }
         priv->signals.clear();


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