Re: [Vala] Problem with struct properties



After a chat with Lethalman__ on irc I filed a bug for the problem under https://bugzilla.gnome.org/show_bug.cgi?id=625758

- Erwin


Erwin Rol wrote:
Hello all,

I am rather new to vala but I just wanted to give it a try. But I hate to say it, but the first thing I tried directly ended up being a SIGSEGV generation tool :-) Of course that might not be vala's fault, but i don't see what i am doing wrong.

I have the following code (my real program was bigger, but this test prog segfaults in the same way), and it segfaults when trying to set the second property. What am i (or what is vala) doing wrong here ?

struct TestStruct {
    public int dummy;
}

class TestClass : Object {
        public int test_int { get; set; }
        public TestStruct test_struct { get; set; }
}

static int main(string[] args)
{
        TestClass tc = new TestClass();

        int ti = 10;
        tc.set("test_int", ti);

        TestStruct ts = TestStruct(){ dummy = 0 };
        tc.set("test_struct", ts);  // <---- SIGSEGV

        return 0;
}

The gdb back trace is as follows. (and doing *value when value == NULL doesn't sound like a smart thing)

Starting program: /home/erwin/vala/test

Program received signal SIGSEGV, Segmentation fault.
0x0000000000400fd0 in testclass_set_test_struct (self=0x2227010, value=0x0) at test.c:141
141        self->priv->_test_struct = *value;
(gdb) bt
#0 0x0000000000400fd0 in testclass_set_test_struct (self=0x2227010, value=0x0) at test.c:141 #1 0x000000000040130a in testclass_set_property (object=0x2227010, property_id=2, value=0x7fffad852f70, pspec=0x2226800) at test.c:208 #2 0x0000003ca2e10433 in IA__g_object_set_valist (object=<value optimized out>, first_property_name=<value optimized out>, var_args=<value optimized out>) at gobject.c:697 #3 0x0000003ca2e108b4 in IA__g_object_set (_object=<value optimized out>, first_property_name=<value optimized out>) at gobject.c:1212 #4 0x0000000000401410 in _vala_main (args=0x7fffad853228, args_length1=1) at test.vala:18 #5 0x0000000000401454 in main (argc=1, argv=0x7fffad853228) at test.vala:10
(gdb)


TIA,

Erwin





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