Critical when setting default value for array property
Submitted by Adrien Bustany
Link to original bug (#610284)
Description
Array properties are not declared as properties in the _class_init function, Vala only creates _get and _set functions. There is a reduced test case below. Note, this example also shows bug #585847.
public class Foo
{
public string[] prop { get; set; }
public void run ()
{
message ("setting the property");
prop = { "apple", "bananas", "oranges" };
message ("We know have %d elements", prop.length);
}
public void print_fruits ()
{
stdout.printf ("Our basket is full of\n");
foreach (var s in prop)
stdout.printf ("%s\n", s);
}
public static void main (string[] args)
{
Foo f = new Foo ();
f.run ();
f.print_fruits ();
}
}
Generated code (class_init only)
static void foo_class_init (FooClass * klass) {
foo_parent_class = g_type_class_peek_parent (klass);
FOO_CLASS (klass)->finalize = foo_finalize;
g_type_class_add_private (klass, sizeof (FooPrivate));
}
Version: 0.7.x
Edited by Rico Tzschichholz