On Wed, Mar 18, 2009 at 8:25 AM, Dr. Michael J. Chudobiak
<m...@avtechpulse.com> wrote:
> I've never fully understood the timing issues with signals and callbacks. Is
> this good or evil (vala) code?
>
>
> public bool ensureConnected () {
>    /* try to connect, if not already connected */
>    if (!connectButton.get_active())
>         connectButton.set_active(true);
>    /* are we connected now? */
>    return connectButton.get_active();
> }
>
> The last line is support to report back whether or not the preceding
> "set_active(true)" was successful. Some error in the code call by the
> set_active signal could have caused it to revert to the false state.
>
> Anyway, I guess the question is: has all code tied to the set_active(true)
> signal executed before the last line?

I dont know vala at all and I can tell you yes this code is perfectly safe,
assuming the signal is implemented as a GSignal, which is a pretty
safe assumption (someone will soon correct me if I'm wrong though ;-)).

Signals in GObject execute synchronously so nothing to worry about.

Cheers,
           -Tristan
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to