diff options
author | Mathieu Duponchelle <mathieu@centricular.com> | 2018-02-16 00:49:25 +0100 |
---|---|---|
committer | Mathieu Duponchelle <mathieu@centricular.com> | 2018-02-16 17:56:17 +0100 |
commit | 9978b521450d9b2a038d48492550dcab49c7b113 (patch) | |
tree | 728947681e53a37858d01db023897e13a8a0be58 | |
parent | e41dd91e9e62eeaeaa0fee97b50500591a87b249 (diff) | |
download | pygobject-9978b521450d9b2a038d48492550dcab49c7b113.tar.gz |
pygi-struct-marshal: perform boxed copy ...
when the cleanup marshaller will not be called, that is when
marshalling something that is not actually an argument.
Fixes #164
-rw-r--r-- | gi/pygi-struct-marshal.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/gi/pygi-struct-marshal.c b/gi/pygi-struct-marshal.c index 44797e75..75896a86 100644 --- a/gi/pygi-struct-marshal.c +++ b/gi/pygi-struct-marshal.c @@ -364,15 +364,14 @@ arg_foreign_from_py_cleanup (PyGIInvokeState *state, } } - -PyObject * -pygi_arg_struct_to_py_marshal (GIArgument *arg, - GIInterfaceInfo *interface_info, - GType g_type, - PyObject *py_type, - GITransfer transfer, - gboolean is_allocated, - gboolean is_foreign) +static PyObject * +pygi_arg_struct_to_py_marshaller (GIArgument *arg, + GIInterfaceInfo *interface_info, + GType g_type, + PyObject *py_type, + GITransfer transfer, + gboolean is_allocated, + gboolean is_foreign) { PyObject *py_obj = NULL; @@ -431,6 +430,23 @@ pygi_arg_struct_to_py_marshal (GIArgument *arg, return py_obj; } +PyObject * +pygi_arg_struct_to_py_marshal (GIArgument *arg, + GIInterfaceInfo *interface_info, + GType g_type, + PyObject *py_type, + GITransfer transfer, + gboolean is_allocated, + gboolean is_foreign) +{ + PyObject *ret = pygi_arg_struct_to_py_marshaller (arg, interface_info, g_type, py_type, transfer, is_allocated, is_foreign); + + if (ret && PyObject_IsInstance (ret, (PyObject *) &PyGIBoxed_Type) && transfer == GI_TRANSFER_NOTHING) + _pygi_boxed_copy_in_place ((PyGIBoxed *) ret); + + return ret; +}; + static PyObject * arg_struct_to_py_marshal_adapter (PyGIInvokeState *state, PyGICallableCache *callable_cache, @@ -441,13 +457,13 @@ arg_struct_to_py_marshal_adapter (PyGIInvokeState *state, PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; PyObject *ret; - ret = pygi_arg_struct_to_py_marshal (arg, - iface_cache->interface_info, - iface_cache->g_type, - iface_cache->py_type, - arg_cache->transfer, - arg_cache->is_caller_allocates, - iface_cache->is_foreign); + ret = pygi_arg_struct_to_py_marshaller (arg, + iface_cache->interface_info, + iface_cache->g_type, + iface_cache->py_type, + arg_cache->transfer, + arg_cache->is_caller_allocates, + iface_cache->is_foreign); *cleanup_data = ret; |