diff options
Diffstat (limited to 'gi/pygi-invoke.c')
-rw-r--r-- | gi/pygi-invoke.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c index 64b3f31..71d5859 100644 --- a/gi/pygi-invoke.c +++ b/gi/pygi-invoke.c @@ -343,9 +343,20 @@ _prepare_invocation_state (struct invocation_state *state, /* if caller allocates only use one level of indirection */ state->out_args[out_args_pos].v_pointer = NULL; state->args[i] = &state->out_args[out_args_pos]; - if (g_type_is_a (g_registered_type_info_get_g_type (info), G_TYPE_BOXED)) + if (g_type_is_a (g_registered_type_info_get_g_type (info), G_TYPE_BOXED)) { state->args[i]->v_pointer = _pygi_boxed_alloc (info, NULL); - else { + } else if (g_struct_info_is_foreign((GIStructInfo *) info) ) { + PyObject *foreign_struct = + pygi_struct_foreign_convert_from_g_argument(state->arg_type_infos[i], NULL); + + pygi_struct_foreign_convert_to_g_argument( + foreign_struct, + state->arg_type_infos[i], + GI_TRANSFER_EVERYTHING, + state->args[i]); + + Py_DECREF(foreign_struct); + } else { gssize size = g_struct_info_get_size ( (GIStructInfo *) info); state->args[i]->v_pointer = g_malloc0 (size); } @@ -548,8 +559,16 @@ _invoke_function (struct invocation_state *state, error = NULL; + pyg_begin_allow_threads; retval = g_function_info_invoke ( (GIFunctionInfo *) function_info, - state->in_args, state->n_in_args, state->out_args, state->n_out_args, &state->return_arg, &error); + state->in_args, + state->n_in_args, + state->out_args, + state->n_out_args, + &state->return_arg, + &error); + pyg_end_allow_threads; + if (!retval) { g_assert (error != NULL); /* TODO: raise the right error, out of the error domain. */ |