This also affects TaskAction and other ListeningAction subclasses.
Code like the following doesn't work as expected:
class WatchedObject(HasTraits):
#: Trait to watch for enabled state
is_enabled = Bool(False)
object = WatchedObject()
action = ListeningAction(object=object, enabled_name="is_enabled")
assert not action.enabled
A similar problem occurs with visible instead of enabled.
When the trait observers are connected to a new object or trait to listen to (including at object init time) the current value of the observed trait is not being transferred across to the action, so the action and the object watched can start in an out-of-sync state.
This hadn't been noticed presumably due to defaults generally agreeing (most actions are going to start enabled and visible).
This also affects
TaskAction
and otherListeningAction
subclasses.Code like the following doesn't work as expected:
A similar problem occurs with
visible
instead ofenabled
.When the trait observers are connected to a new object or trait to listen to (including at object init time) the current value of the observed trait is not being transferred across to the action, so the action and the object watched can start in an out-of-sync state.
This hadn't been noticed presumably due to defaults generally agreeing (most actions are going to start enabled and visible).