Commit d8e241e2 authored by Martin Pitt's avatar Martin Pitt
Browse files

Fix C to Python marshalling of struct pointer arrays

Do not treat an array of pointers to values like an array of values on
marshalling from C. This makes the test_array_boxed_struct_return() test case
parent 60544b02
......@@ -434,13 +434,14 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
item_arg.v_pointer = g_variant_ref_sink (g_array_index (array_, gpointer, i));
item_arg.v_pointer = g_array_index (array_, gpointer, i);
} else if (arg_cache->transfer == GI_TRANSFER_EVERYTHING) {
} else if (arg_cache->transfer == GI_TRANSFER_EVERYTHING && !item_arg_cache->is_pointer) {
/* array elements are structs */
gpointer *_struct = g_malloc (item_size);
memcpy (_struct, array_->data + i * item_size,
item_arg.v_pointer = _struct;
} else if (item_arg_cache->is_pointer)
/* this is the case for GAtom* arrays */
/* array elements are pointers to values */
item_arg.v_pointer = g_array_index (array_, gpointer, i);
item_arg.v_pointer = array_->data + i * item_size;
......@@ -836,13 +836,11 @@ class TestArray(unittest.TestCase):
self.assertEqual(1, struct1.long_)
def test_array_boxed_struct_return(self):
(struct1, struct2, struct3) = GIMarshallingTests.array_zero_terminated_return_struct()
self.assertEqual(GIMarshallingTests.BoxedStruct, type(struct1))
self.assertEqual(GIMarshallingTests.BoxedStruct, type(struct2))
self.assertEqual(GIMarshallingTests.BoxedStruct, type(struct3))
# FIXME: gets bogus values
self.assertEqual(42, struct1.long_)
self.assertEqual(43, struct2.long_)
self.assertEqual(44, struct3.long_)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment