[gjs/halfline/debug-metrics: 4/4] object: Fix small trampoline leak
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/halfline/debug-metrics: 4/4] object: Fix small trampoline leak
- Date: Tue, 21 Dec 2021 17:47:21 +0000 (UTC)
commit b8659e5ccb46796cd04fbea0f9a17f37f705192b
Author: Ray Strode <rstrode redhat com>
Date: Wed Dec 15 10:55:26 2021 -0500
object: Fix small trampoline leak
gi/object.cpp | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index fe381ec3..88acf72a 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1428,7 +1428,7 @@ invalidate_all_closures(ObjectInstance *priv)
* invalidate notifier */
while (!priv->closures.empty()) {
/* This will also free cd, through the closure invalidation mechanism */
- GClosure *closure = *priv->closures.begin();
+ GClosure *closure = g_closure_ref (*priv->closures.begin());
g_closure_invalidate(closure);
/* Erase element if not already erased */
priv->closures.erase(closure);
@@ -2435,6 +2435,14 @@ find_vfunc_info (JSContext *context,
g_base_info_unref(struct_info);
}
+static void
+free_trampoline (GjsCallbackTrampoline *trampoline,
+ GClosure *closure)
+{
+ gjs_callback_trampoline_unref(trampoline);
+ g_closure_unref (closure);
+}
+
static bool
gjs_hook_up_vfunc(JSContext *cx,
unsigned argc,
@@ -2524,6 +2532,7 @@ gjs_hook_up_vfunc(JSContext *cx,
trampoline = gjs_callback_trampoline_new(cx, v_function, vfunc,
GI_SCOPE_TYPE_NOTIFIED,
object, true);
+ g_closure_add_invalidate_notifier (trampoline->js_function, trampoline, (GClosureNotify)
free_trampoline);
*((ffi_closure **)method_ptr) = trampoline->closure;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]