diff options
author | Campbell Barton <campbell@blender.org> | 2022-05-05 13:18:44 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-05-05 13:18:44 +0300 |
commit | c7a345bd60d340449bf03646bc04624fe2396bb3 (patch) | |
tree | 3d1a0055923403b97c60807c28aeca73b64696e2 /source | |
parent | 960a1ddd8588acd1f49adfc2486f55e950fb6448 (diff) | |
parent | 598917f49b3564c1ca1b28907547332d69a85328 (diff) |
Merge branch 'blender-v3.2-release'
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index e84b6485596..8c7cf86d050 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -492,6 +492,14 @@ bool WM_toolsystem_key_from_context(ViewLayer *view_layer, ScrArea *area, bToolK void WM_toolsystem_refresh_active(bContext *C) { Main *bmain = CTX_data_main(C); + + struct { + wmWindow *win; + ScrArea *area; + ARegion *region; + bool is_set; + } context_prev = {0}; + for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace = WM_window_get_active_workspace(win); @@ -511,6 +519,16 @@ void WM_toolsystem_refresh_active(bContext *C) }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); if (tref != area->runtime.tool) { + if (context_prev.is_set == false) { + context_prev.win = CTX_wm_window(C); + context_prev.area = CTX_wm_area(C); + context_prev.region = CTX_wm_region(C); + context_prev.is_set = true; + } + + CTX_wm_window_set(C, win); + CTX_wm_area_set(C, area); + toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); } } @@ -518,6 +536,12 @@ void WM_toolsystem_refresh_active(bContext *C) } } + if (context_prev.is_set) { + CTX_wm_window_set(C, context_prev.win); + CTX_wm_area_set(C, context_prev.area); + CTX_wm_region_set(C, context_prev.region); + } + BKE_workspace_id_tag_all_visible(bmain, LIB_TAG_DOIT); LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) { @@ -608,6 +632,16 @@ bToolRef *WM_toolsystem_ref_set_by_id_ex( if (ot == NULL) { return NULL; } + + /* Some contexts use the current space type (image editor for e.g.), + * ensure this is set correctly or there is no area. */ +#ifndef NDEBUG + { + ScrArea *area = CTX_wm_area(C); + BLI_assert(area == NULL || area->spacetype == tkey->space_type); + } +#endif + PointerRNA op_props; WM_operator_properties_create_ptr(&op_props, ot); RNA_string_set(&op_props, "name", name); |