On Mon, Dec 14, 2009 at 1:35 PM, Darren Warner <[email protected]> wrote:
> Hi Michael,
>
> I think this is the same problem I was experiencing (though I get it with
> vala 0.7.6 as well, so I'm not sure why this was previously working for
> you).

Well, it hasn't worked since I added that line, on this project...

> The problem is that bad code being generated by vala - 'self' is being used
> before it is being initialized. The following simplified code will reproduce
> the problem:

D'oh!  Now that I look at the generated code more closely, I see that.
 So I suppose that means that there is a bug in Vala (anyone know if
it has been fixed yet?  I suppose I can go build trunk and see…).
Crap, that means my desire to depend on Vala 0.7.6 as a minimum is
out.  Oh, well.

> public class Bar : GLib.Object {
>    private ThreadedSocketService m_service;
>    private uint16 m_max_connections;
>
>    public Bar() {
>        m_service = new ThreadedSocketService(10);
>        m_service.max_threads = m_max_connections;
>    }
> }
>
> Compiling with 'valac -C bar.vala --pkg=gio-2.0' will produce the following:
>
> Bar* bar_construct (GType object_type) {
>        GParameter * __params;
>        GParameter * __params_it;
>        GThreadedSocketService* _tmp0_;
>        Bar * self;
>        __params = g_new0 (GParameter, 1);
>        __params_it = __params;
>        self->priv->m_service = (_tmp0_ = (GThreadedSocketService*)
> g_threaded_socket_service_new (10), _g_object_unref0
> (self->priv->m_service), _tmp0_);
>        ...
>        self = g_object_newv (object_type, __params_it - __params, __params);
>
>
> I don't know what it is about ThreadedSocketService, but I cannot reproduce
> the problem if I use a simple 'Foo' class instead, even if it is derived
> from GLib.Object. Bar does need to be constructed from GLib.Object - the bug
> is related to some kind of readahead optimization maybe?
>
> I was going to raise a bug about this, but wanted to check if you were
> having the same problem as well - seems you are.

It would seem so.  Do you want to file the bug report, or shall I?
Since the short example is something you already have, and the problem
is still in trunk… I'd guess you probably want to?

   --- Mike
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to