On Sat, Oct 24, 2009 at 4:44 PM, pHilipp Zabel <philipp.za...@gmail.com> wrote: > On Sat, Oct 24, 2009 at 12:59 PM, Jan Hudec <b...@ucw.cz> wrote: >> On Fri, Oct 23, 2009 at 15:31:53 +0200, pHilipp Zabel wrote: >>> Hi, >>> >>> I'd like to call a delegate function from an async function, like this: >>> >>> class AsyncDelegate { >>> delegate void TestFunc (); >>> >>> void test_func () { >>> print ("delegate\n"); >>> } >>> >>> async void test_async (TestFunc f) { >> >> Can you try it with >> >> async void test_async (owned TestFunc f) { >> >> ? > > Thanks, but that doesn't work either. > I filed a bug, details at https://bugzilla.gnome.org/show_bug.cgi?id=599487 > > The first problem is that the AsyncDelegateTestFunc delegate typedef > in the generated code appears only after the struct > _AsyncDelegateTestAsyncData, in which it is referenced. > > The second problem is that the struct _AsyncDelegateTestAsyncData is > missing a GDestroyNotify f_target_destroy_notify member, even after I > add the owned keyword as you suggest.
With Jürg's help I came up with a patch (http://bugzilla-attachments.gnome.org/attachment.cgi?id=146187) that fixes both problems. I still get the critical error message, though: ** (valac:1106): CRITICAL **: vala_data_type_get_value_owned: assertion `self != NULL' failed Any idea where this is coming from? >>> print ("async enter\n"); >>> Idle.add (test_async.callback); >>> yield; >>> f (); >>> print ("async leave\n"); >>> } >>> >>> static int main (string[] args) { >>> var loop = new GLib.MainLoop (null, false); >>> var app = new AsyncDelegate (); >>> >>> app.test_async.begin (app.test_func); >>> print ("loop\n"); >>> loop.run (); >>> >>> return 0; >>> } >>> } >>> >>> But Vala 0.7.7 doesn't like that at all: >>> >>> ** (valac:7627): CRITICAL **: vala_data_type_get_value_owned: >>> assertion `self != NULL' failed >>> /home/ph5/vala/async-delegate/async-delegate.vala.c:44: error: >>> expected specifier-qualifier-list before Б─≤AsyncDelegateTestFuncБ─≥ >>> [...] >>> Compilation failed: 1 error(s), 0 warning(s) >> >> It can't work with unowned delegate (add 'owned' as mentioned above), because >> vala can't guarantee the invocant will be valid by the time the async >> function gets to call it. >> >> However, vala should report an understandable error, so filing a bug would be >> appropriate. > > I see. I filed a second bug for the error messages: > https://bugzilla.gnome.org/show_bug.cgi?id=599488 And for this one I've got a patch proposal, too: http://bugzilla-attachments.gnome.org/attachment.cgi?id=146188 regards Philipp _______________________________________________ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list