enthought / envisage

Envisage is a Python-based framework for building applications whose functionalities can be extended by adding "plug-ins".
http://docs.enthought.com/envisage/
Other
82 stars 26 forks source link

PreferencesPane triggers preferences update prematurely #582

Closed mdickinson closed 2 weeks ago

mdickinson commented 2 months ago

When opening the PreferencesPane, nodes in the underlying Preferences sometimes get updated immediately, exactly as a result of Envisage's attempts to make sure that doesn't happen.

The relevant code is here: https://github.com/enthought/envisage/blob/4ec68a482a2ff1e5a92828d0cceaf79d808fc177/envisage/ui/tasks/preferences_pane.py#L67-L69

The issue is with the clone_traits: at some point, the clone_traits operation will clone the preferences trait. Any preference value cloned after that happens will trigger an update back to the Preferences model, through the _anytrait_changed handler on PreferencesHelper. The line after clone_traits sets preferences to None so that changes to the helper are not propagated to the preferences node, but at that point it's too late for the changes that have already been propagated.