[gjs] Fix ref count of (transfer full) GObject arguments.



commit 03671d6002aca4cc22c101be4cde9b3c076d4281
Author: C. Scott Ananian <cscott litl com>
Date:   Wed May 6 22:58:08 2009 -0400

    Fix ref count of (transfer full) GObject arguments.
    
    We need to ref the gobject when creating an in-argument so to match the
    unref in g_arg_release_internal (for transfer none).  When using
    (transfer full), the additional ref is the ref we are going to transfer
    to the native code; our original ref is still held by the JavaScript wrapper
    until the JS wrapper is garbage collected.
---
 gi/arg.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gi/arg.c b/gi/arg.c
index aa56b23..845a704 100644
--- a/gi/arg.c
+++ b/gi/arg.c
@@ -480,7 +480,8 @@ gjs_value_to_g_argument(JSContext      *context,
                                           g_type_name(G_TYPE_FROM_INSTANCE(arg->v_pointer)));
                                 arg->v_pointer = NULL;
                                 wrong = TRUE;
-                            }
+                            } else
+                                g_object_ref(G_OBJECT(arg->v_pointer));
                         }
                     } else if (g_type_is_a(gtype, G_TYPE_BOXED)) {
                         if (g_type_is_a(gtype, G_TYPE_CLOSURE)) {



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