is this good code?



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?

- Mike






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