[gjs] Fix callbacks with scope=call that call the callback multiple times



commit 1dc796655dc4a00a9c42fc85a3113e43997f16ee
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sun May 9 14:01:35 2010 -0400

    Fix callbacks with scope=call that call the callback multiple times
    
    A callback with scope=call is allowed to be called multiple times
    before the call returns. For this reason, we can't treat the
    trampoline like a scope=async trampoline and schedule it for
    freeing when the callback returns, instead we need to free it
    when outer call returns.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=618190

 gi/function.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/gi/function.c b/gi/function.c
index ad1b20b..1aac362 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -202,7 +202,7 @@ gjs_callback_closure(ffi_cif *cif,
     }
 
 out:
-    if (trampoline->scope != GI_SCOPE_TYPE_NOTIFIED) {
+    if (trampoline->scope == GI_SCOPE_TYPE_ASYNC) {
         completed_trampolines = g_slist_prepend(completed_trampolines, trampoline);
     }
 }
@@ -599,6 +599,11 @@ gjs_invoke_c_function(JSContext      *context,
     }
 
 release:
+    if (callback_trampoline &&
+        callback_trampoline->scope == GI_SCOPE_TYPE_CALL) {
+        gjs_callback_trampoline_free(callback_trampoline);
+    }
+
     /* We walk over all args, release in args (if allocated) and convert
      * all out args to JS
      */



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