Commit 9c48a561 authored by Bastian Winkler's avatar Bastian Winkler Committed by Martin Pitt
Browse files

Fix len_arg_index for array arguments

Don't set len_arg_index for arrays without the length annotation given.
This fixes methods like Clutter.Texture.set_from_rgb_data() and
Clutter.Image.set_data()

https://bugzilla.gnome.org/show_bug.cgi?id=674271

Signed-off-by: default avatarMartin Pitt <martinpitt@gnome.org>
parent 71246ca0
......@@ -161,7 +161,9 @@ _sequence_cache_new (GITypeInfo *type_info,
if (!sc->is_zero_terminated) {
sc->fixed_size = g_type_info_get_array_fixed_size (type_info);
if (sc->fixed_size < 0)
sc->len_arg_index = g_type_info_get_array_length (type_info) + child_offset;
sc->len_arg_index = g_type_info_get_array_length (type_info);
if (sc->len_arg_index >= 0)
sc->len_arg_index += child_offset;
}
item_type_info = g_type_info_get_param_type (type_info, 0);
......
......@@ -279,13 +279,13 @@ _wrap_c_array (PyGIInvokeState *state,
gpointer data)
{
GArray *array_;
gsize len;
gsize len = 0;
if (sequence_cache->fixed_size >= 0) {
len = sequence_cache->fixed_size;
} else if (sequence_cache->is_zero_terminated) {
len = g_strv_length ((gchar **)data);
} else {
} else if (sequence_cache->len_arg_index >= 0) {
GIArgument *len_arg = state->args[sequence_cache->len_arg_index];
len = len_arg->v_long;
}
......
......@@ -744,6 +744,9 @@ class TestArray(unittest.TestCase):
GIMarshallingTests.multi_array_key_value_in(["one", "two", "three"],
[1, 2, 3])
def test_array_in_nonzero_nonlen(self):
GIMarshallingTests.array_in_nonzero_nonlen(1, 'abcd')
def test_array_fixed_out_struct(self):
struct1, struct2 = GIMarshallingTests.array_fixed_out_struct()
......
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