summaryrefslogtreecommitdiff
path: root/gi/pygi-marshal-cleanup.c
diff options
context:
space:
mode:
Diffstat (limited to 'gi/pygi-marshal-cleanup.c')
-rw-r--r--gi/pygi-marshal-cleanup.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index bd9522a..d7d1b63 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -29,7 +29,7 @@ _cleanup_caller_allocates (PyGIInvokeState *state,
{
PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)cache;
- if (iface_cache->g_type == G_TYPE_BOXED) {
+ if (g_type_is_a (iface_cache->g_type, G_TYPE_BOXED)) {
gsize size;
if (was_processed)
return; /* will be cleaned up at deallocation */
@@ -101,6 +101,12 @@ pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState *state,
arg_cache->direction == PYGI_DIRECTION_FROM_PYTHON &&
state->args[i]->v_pointer != NULL)
cleanup_func (state, arg_cache, state->args[i]->v_pointer, TRUE);
+
+ if (cleanup_func &&
+ arg_cache->direction == PYGI_DIRECTION_BIDIRECTIONAL &&
+ state->args_data[i] != NULL) {
+ cleanup_func (state, arg_cache, state->args_data[i], TRUE);
+ }
}
}
@@ -368,8 +374,17 @@ _pygi_marshal_cleanup_from_py_array (PyGIInvokeState *state,
else if (sequence_cache->item_cache->is_pointer)
item = g_array_index (array_, gpointer, i);
/* case 3: C array or GArray with simple types or structs */
- else
+ else {
item = array_->data + i * sequence_cache->item_size;
+ /* special-case hack: GValue array items do not get slice
+ * allocated in _pygi_marshal_from_py_array(), so we must
+ * not try to deallocate it as a slice and thus
+ * short-circuit cleanup_func. */
+ if (cleanup_func == _pygi_marshal_cleanup_from_py_interface_struct_gvalue) {
+ g_value_unset ((GValue*) item);
+ continue;
+ }
+ }
cleanup_func (state, sequence_cache->item_cache, item, TRUE);
}