Commit 2162a9b1 authored by Torsten Schönfeld's avatar Torsten Schönfeld

Correctly marshal arrays with length arguments in signal callbacks

Signals have an implicit invocant, and hence their argument indexing is off by
one.
parent 268cf876
......@@ -358,8 +358,10 @@ _prepare_perl_invocation_info (GPerlI11nPerlInvocationInfo *iinfo,
if (arg_tag == GI_TYPE_TAG_ARRAY) {
gint pos = g_type_info_get_array_length (arg_type);
if (pos >= 0) {
GITypeInfo *length_arg_type = &(iinfo->base.arg_types[pos]);
raw_to_arg (args[pos], &iinfo->base.aux_args[pos], length_arg_type);
GITypeInfo *length_arg_type;
guint args_pos = iinfo->base.is_signal ? pos+1 : pos;
length_arg_type = &(iinfo->base.arg_types[pos]);
raw_to_arg (args[args_pos], &iinfo->base.aux_args[pos], length_arg_type);
dwarn (" pos %d is array length => %"G_GSIZE_FORMAT"\n",
pos, iinfo->base.aux_args[pos].v_size);
}
......
......@@ -6,7 +6,7 @@ use strict;
use warnings;
use utf8;
plan tests => 68;
plan tests => 72;
ok (Regress::test_strv_in ([ '1', '2', '3' ]));
......@@ -163,3 +163,17 @@ SKIP: {
is_deeply (GI::bytearray_full_return (), $byte_array_ref);
GI::bytearray_none_in ($byte_array_ref);
}
# -----------------------------------------------------------------------------
{
my $obj = Regress::TestObj->constructor ();
$obj->signal_connect ('sig-with-array-len-prop' => sub {
my ($self, $array, $len, $data) = @_;
is ($self, $obj);
is_deeply ($array, [0, 1, 2, 3, 4]);
is ($len, 5);
is ($data, 'user23');
}, 'user23');
$obj->emit_sig_with_array_len_prop ();
}
......@@ -34,7 +34,10 @@ Glib::Object::Introspection->setup(
basename => 'Regress',
version => '1.0',
package => 'Regress',
search_path => 'build');
search_path => 'build',
use_generic_signal_marshaller_for => [
['Regress::TestObj', 'sig-with-array-len-prop'],
]);
Glib::Object::Introspection->setup(
basename => 'GIMarshallingTests',
......
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