Hi folks, Obvious use for lambdas is connecting them to signals, right? But how does one disconnect them?
The tutorial suggests code like: t1.sig_1.connect((t, a) => { stdout.printf("%d\n", a); }); (where sig_1 is declared as "public signal void sig_1(int a);" Fine. Now say I need to explicitly disconnect for some reason. However, t1.sig_1.disconnect((t, a) => { stdout.printf("%d\n", a); }); will NOT achieve that, because it will produce a new closure and that is not connected, so nothing will be disconnected. So, what options we have? - Store the closure to a variable. I tried it, but couldn't get signal to accept that variable. So if you suggest it, please first try to actually compile it to see it actually works (in 0.7.6 or newer). - Somehow disconnect by id. It would be nice, but I don't know where to get the id (t1.sig_1.connect(...) is a void expression). Than if disconnect does not accept id, the g_signal_handler_disconnect would need to be bound (it's missing from gobject-2.0.vapi) and used. - Use one of GLib.Signal.connect_*. They take raw function and data pointers or GLib.Closure and I don't know how to convert a delegate to either. Besides, the GLib.Signal.handler_disconnect is missing from the .vapi. Any other idea? Thanks, Jan -- Jan 'Bulb' Hudec <b...@ucw.cz> _______________________________________________ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list