2014-03-09 21:06 GMT+01:00 Martin Owens <doctormo@...400...>:
Hey Devs,
I was reviewing some of the ponyscape merge today and I noticed in the object's dialog Janeczko used signal.block() and signal.unblock() to deny signals and I suspect to prevent loops and such.
Is this a good pattern to use?
Blocking signal emission is OK if done from the object that emits the signal, for example to prevent recursively calling the same callback. A common pattern is to do something in response to a 'changed' signal that itself might invoke a 'changed' signal; in this case calling block() in the handler is perfectly acceptable. In other cases it should be used with care.
The first thing you should consider is controlling the order of slot invocation. You can do this by using slots().insert() instead of connect() to put the new slot in the first place on the list rather than the last - see for example connectChangedFirst() in selection.cpp.
Regards, Krzysztof