Here's what the code would do before this change:
- Object mode change operators did:
- Call WM_toolsystem_update_from_context_view3d() - activates the default tool if needed.
- Send a message notifier that would cause toolsystem refreshing, see WM_toolsystem_do_msg_notify_tag_refresh().
- Area reinitialization - ED_area_init() - did:
- Set AREA_FLAG_ACTIVE_TOOL_UPDATE causing a WM_toolsystem_update_from_context() call - activates the default tool if needed.
- Cause toolsystem refreshing.
So both ways would basically do the same, yet do it in rather different & confusing ways.
Idea of this patch is to move AREA_FLAG_ACTIVE_TOOL_UPDATE setting to the toolsystem refreshing, which is called by area reinitialization, undo/redo and WM_toolsystem_do_msg_notify_tag_refresh(). That way we don't have to call WM_toolsystem_update_from_context(_view3d)() in mode change operators anymore and do it all through the message-bus.
I found this while investigating why the default Clip Editor tool (WIP in tracking_tools branch) wouldn't be set when switching modes. With this change you only have to make sure the message-bus is notified when the mode changes and that the area responds to that with a WM_toolsystem_do_msg_notify_tag_refresh() call.
Note that for the sequencer this only happened to work because changing modes would hide/unhide regions, causing ED_area_init() to be called.