diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-15 01:43:02 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-15 01:48:20 +0300 |
commit | 7f8f362e018e99376387ed62629749024acab28d (patch) | |
tree | 6f261af9051e50b14abcb0b99efb303d8106428c /source/blender/windowmanager/intern/wm_toolsystem.c | |
parent | ded8f5cc1903ce848fc88b102b76140fb1a21937 (diff) |
Tool System: avoid redundant refresh
Workspaces refreshes tools multiple times when used by multiple windows.
Also improve comments.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_toolsystem.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 773f02e2591..92ef235722b 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -549,7 +549,6 @@ bool WM_toolsystem_key_from_context(ViewLayer *view_layer, ScrArea *sa, bToolKey void WM_toolsystem_refresh_active(bContext *C) { Main *bmain = CTX_data_main(C); - BKE_main_id_tag_idcode(bmain, ID_WS, LIB_TAG_DOIT, false); for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { for (wmWindow *win = wm->windows.first; win; win = win->next) { WorkSpace *workspace = WM_window_get_active_workspace(win); @@ -573,13 +572,19 @@ void WM_toolsystem_refresh_active(bContext *C) } } } + } + } - if ((workspace->id.tag & LIB_TAG_DOIT) == 0) { - workspace->id.tag |= LIB_TAG_DOIT; - /* Refresh to ensure data is initialized, see: T64339. */ - for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { - toolsystem_refresh_ref(C, workspace, tref); - } + BKE_workspace_id_tag_all_visible(bmain, LIB_TAG_DOIT); + + LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) { + if (workspace->id.tag & LIB_TAG_DOIT) { + workspace->id.tag &= ~LIB_TAG_DOIT; + /* Refresh to ensure data is initialized. + * This is needed because undo can load a state which no longer has the underlying DNA data + * needed for the tool (un-initialized paint-slots for eg), see: T64339. */ + for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { + toolsystem_refresh_ref(C, workspace, tref); } } } |