I seem unable to come up with an elegant solution. Maybe this is a design flaw in how the tools are handled. Every time you switch the currently active tool, a new tool instance is created and the old one is destroyed.
If each window owned a set of tool instances that live as long as the window exists this wouldn't be a problem. Only on window creation every tool should read the prefs and when closing the window, every tool should write back its current state to the prefs. During window lifetime, a tool should only react to certain changes in the prefs (using the already existing PrefsObserver and the virtual set-method).
Currently, every change in a tool's settings is immediately written back to the prefs, e. g. in pencil-toolbar.cpp (sp_add_freehand_mode_toggle, freehand_mode_changed).
I seem unable to come up with an elegant solution. Maybe this is a design flaw in how the tools are handled. Every time you switch the currently active tool, a new tool instance is created and the old one is destroyed.
If each window owned a set of tool instances that live as long as the window exists this wouldn't be a problem. Only on window creation every tool should read the prefs and when closing the window, every tool should write back its current state to the prefs. During window lifetime, a tool should only react to certain changes in the prefs (using the already existing PrefsObserver and the virtual set-method).
Currently, every change in a tool's settings is immediately written back to the prefs, e. g. in pencil-toolbar.cpp (sp_add_ freehand_ mode_toggle, freehand_ mode_changed) .
I'll try this out.