diff options
author | Bastien Montagne <bastien@blender.org> | 2021-10-26 18:23:38 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-10-29 12:32:26 +0300 |
commit | 51c1c1cd938f990333b09d89fb063bb28864b302 (patch) | |
tree | d1533902832d1382ab0351b71c6621552ff3bb0f /source/blender/windowmanager/intern | |
parent | eae59645def368a46c546a5d88db4b885f707b9b (diff) |
Fix potential early-return in WM foreach_id process.
Add a function to check if iteration over ID usages should stop (using
internal `IDWALK_STOP` status flag).
Use it in `BKE_LIB_FOREACHID_PROCESS_` macros, and in
`window_manager_foreach_id` to handle properly the active workspace case
(previous code could skip the call to `BKE_workspace_active_set` in case
iteration over ID usages was stopped by callback on that specific ID
usage).
Part of T90922: Fix return policy inconsistency in `scene_foreach_id`.
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 4458b386ab6..aa439f619be 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -91,10 +91,14 @@ static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data) /* This pointer can be NULL during old files reading, better be safe than sorry. */ if (win->workspace_hook != NULL) { ID *workspace = (ID *)BKE_workspace_active_get(win->workspace_hook); - BKE_LIB_FOREACHID_PROCESS_ID(data, workspace, IDWALK_CB_NOP); + BKE_lib_query_foreachid_process(data, &workspace, IDWALK_CB_USER); /* Allow callback to set a different workspace. */ BKE_workspace_active_set(win->workspace_hook, (WorkSpace *)workspace); + if (BKE_lib_query_foreachid_iter_stop(data)) { + return; + } } + if (BKE_lib_query_foreachid_process_flags_get(data) & IDWALK_INCLUDE_UI) { LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { BKE_screen_foreach_id_screen_area(data, area); |