[pygobject/invoke-rewrite] [gi-invoke-ng] backport raw gvalue handling



commit fd76423e655b3711e1ffbf9b61ea4e2c94040234
Author: John (J5) Palmieri <johnp redhat com>
Date:   Mon Mar 28 18:32:00 2011 -0400

    [gi-invoke-ng] backport raw gvalue handling

 gi/pygi-marshal.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/gi/pygi-marshal.c b/gi/pygi-marshal.c
index 702c5ab..0c02a14 100644
--- a/gi/pygi-marshal.c
+++ b/gi/pygi-marshal.c
@@ -1217,11 +1217,24 @@ _pygi_marshal_in_interface_struct (PyGIInvokeState   *state,
         }
 
         value = g_slice_new0 (GValue);
-        g_value_init (value, object_type);
-        if (pyg_value_from_pyobject(value, py_arg) < 0) {
-            g_slice_free (GValue, value);
-            PyErr_SetString (PyExc_RuntimeError, "PyObject conversion to GValue failed");
-            return FALSE;
+
+        /* if already a gvalue, copy, else marshal into gvalue */
+        if (object_type == G_TYPE_VALUE) {
+            /* src GValue's lifecycle is handled by Python
+             * so we have to copy it into the destination's
+             * GValue which is freed during the cleanup of
+             * invoke.
+             */
+            GValue *src = (GValue *)((PyGObject *) py_arg)->obj;
+            g_value_init (value, G_VALUE_TYPE (src));
+            g_value_copy (src, value);
+        } else {
+            g_value_init (value, object_type);
+            if (pyg_value_from_pyobject(value, py_arg) < 0) {
+                g_slice_free (GValue, value);
+                PyErr_SetString (PyExc_RuntimeError, "PyObject conversion to GValue failed");
+                return FALSE;
+            }
         }
 
         arg->v_pointer = value;



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