[pygobject] Never dup data structures when marshaling signal in arguments



commit 142ff1903d34876db3d1bee5e9782ac49de12313
Author: Simon Feltman <sfeltman src gnome org>
Date:   Mon Jul 28 04:40:36 2014 -0700

    Never dup data structures when marshaling signal in arguments
    
    Always assume transfer-none of GValue arguments to signal handlers.
    A signal handler with arguments marked as transfer-full does not
    make any sense, so assume they are always transfer-none.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726999

 gi/pygi-signal-closure.c |    4 +---
 gi/pygi-value.c          |    4 +++-
 2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gi/pygi-signal-closure.c b/gi/pygi-signal-closure.c
index 39e0881..0c6b9b9 100644
--- a/gi/pygi-signal-closure.c
+++ b/gi/pygi-signal-closure.c
@@ -109,14 +109,12 @@ pygi_signal_closure_marshal(GClosure *closure,
         } else if (i < sig_info_highest_arg) {
             GIArgInfo arg_info;
             GITypeInfo type_info;
-            GITransfer transfer;
             GIArgument arg = { 0, };
             PyObject *item = NULL;
             gboolean free_array = FALSE;
 
             g_callable_info_load_arg(signal_info, i - 1, &arg_info);
             g_arg_info_load_type(&arg_info, &type_info);
-            transfer = g_arg_info_get_ownership_transfer(&arg_info);
 
             arg = _pygi_argument_from_g_value(&param_values[i], &type_info);
             
@@ -130,7 +128,7 @@ pygi_signal_closure_marshal(GClosure *closure,
                                                          &free_array);
             }
             
-            item = _pygi_argument_to_object (&arg, &type_info, transfer);
+            item = _pygi_argument_to_object (&arg, &type_info, GI_TRANSFER_NOTHING);
             
             if (free_array) {
                 g_array_free (arg.v_pointer, FALSE);
diff --git a/gi/pygi-value.c b/gi/pygi-value.c
index f54f8e1..42cee82 100644
--- a/gi/pygi-value.c
+++ b/gi/pygi-value.c
@@ -80,7 +80,9 @@ _pygi_argument_from_g_value(const GValue *value,
             break;
         case GI_TYPE_TAG_UTF8:
         case GI_TYPE_TAG_FILENAME:
-            arg.v_string = g_value_dup_string (value);
+            /* Callers are responsible for ensuring the GValue stays alive
+             * long enough for the string to be copied. */
+            arg.v_string = (char *)g_value_get_string (value);
             break;
         case GI_TYPE_TAG_GLIST:
         case GI_TYPE_TAG_GSLIST:


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