[Vala] Problem using Gdk.Color as a property



Hi all,

I have a problem to introspect GObject's which contains Gdk.Color. Where
is a small sample:

using Gdk;
public class Foo: Object {
        public string bar { get; set; }
        public Gdk.Color color { get; set; }
/* Generated CCode:
                case FOO_COLOR:
                boxed = g_new0 (GdkColor, 1); WRONG
                boxed = g_slice_new (GdkColor); SHOULD BE
                foo_get_color (self, boxed);
                g_value_take_boxed (value, boxed);
*/
}
void main (string[] args)
{
        Foo obj = new Foo ();
        for (int i = 0; i < 1000; i++) {
                weak ObjectClass klass = obj.get_class ();
                weak ParamSpec[] properties = klass.list_properties ();
                foreach (ParamSpec prop in properties) {
                        Value prop_value = Value (prop.value_type);
                        obj.get_property (prop.name, ref prop_value);
                        /* Hidden g_value_unset,gdk_color_free and g_slice_free calls */
                }
                free (properties);
                
                obj.bar = i.to_string (); // Force memory corruption
        }
}

Running this code causes runtime errors if G_SLICE=always-malloc is not
set. How to avoid this problem? Is it possible to tell Vala to use
g_slice_new instead of g_new0?

Thanks,
Sergey Nizovtsev




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]