diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-10-22 02:12:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-10-22 02:18:59 +0300 |
commit | 3e1baa7d539757b8e5fa870d4909354e0b5645b9 (patch) | |
tree | 4f557a747a061ca6df7455aaae123cc19204c958 /source | |
parent | bdbaf0301df630cefd3f753c9419646b3f858588 (diff) |
Fix T92357: assert changing scenes while in edit mode
ScrArea.runtime.tool needs to be updated after switching scenes.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 5 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_toolsystem.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 32 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 7 |
5 files changed, 36 insertions, 19 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 92aeaf03329..b90c7f27c57 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -210,7 +210,10 @@ void ED_screen_ensure_updated(struct wmWindowManager *wm, struct bScreen *screen); void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note); bool ED_screen_change(struct bContext *C, struct bScreen *screen); -void ED_screen_scene_change(struct bContext *C, struct wmWindow *win, struct Scene *scene); +void ED_screen_scene_change(struct bContext *C, + struct wmWindow *win, + struct Scene *scene, + const bool refresh_toolsystem); void ED_screen_set_active_region(struct bContext *C, struct wmWindow *win, const int xy[2]); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 4d387ad0191..841792d5f2d 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -57,6 +57,7 @@ #include "UI_interface.h" #include "WM_message.h" +#include "WM_toolsystem.h" #include "DEG_depsgraph_query.h" @@ -1239,7 +1240,10 @@ static void screen_set_3dview_camera(Scene *scene, } } -void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene) +void ED_screen_scene_change(bContext *C, + wmWindow *win, + Scene *scene, + const bool refresh_toolsystem) { #if 0 ViewLayer *view_layer_old = WM_window_get_active_view_layer(win); @@ -1277,6 +1281,10 @@ void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene) } } } + + if (refresh_toolsystem) { + WM_toolsystem_refresh_screen_window(win); + } } ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *area, int type) diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 018165634f2..eb89fca7b56 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -134,6 +134,7 @@ void WM_toolsystem_refresh_active(struct bContext *C); void WM_toolsystem_refresh_screen_area(struct WorkSpace *workspace, struct ViewLayer *view_layer, struct ScrArea *area); +void WM_toolsystem_refresh_screen_window(struct wmWindow *win); void WM_toolsystem_refresh_screen_all(struct Main *bmain); #ifdef __cplusplus diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 0c24520d565..3ac1a7c0be1 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -572,25 +572,29 @@ void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, ViewLayer *view_lay } } +void WM_toolsystem_refresh_screen_window(wmWindow *win) +{ + WorkSpace *workspace = WM_window_get_active_workspace(win); + bool space_type_has_tools[SPACE_TYPE_LAST + 1] = {0}; + LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { + space_type_has_tools[tref->space_type] = true; + } + bScreen *screen = WM_window_get_active_screen(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + area->runtime.tool = NULL; + area->runtime.is_tool_set = true; + if (space_type_has_tools[area->spacetype]) { + WM_toolsystem_refresh_screen_area(workspace, view_layer, area); + } + } +} + void WM_toolsystem_refresh_screen_all(Main *bmain) { /* Update all ScrArea's tools */ 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); - bool space_type_has_tools[SPACE_TYPE_LAST + 1] = {0}; - LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { - space_type_has_tools[tref->space_type] = true; - } - bScreen *screen = WM_window_get_active_screen(win); - ViewLayer *view_layer = WM_window_get_active_view_layer(win); - LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - area->runtime.tool = NULL; - area->runtime.is_tool_set = true; - if (space_type_has_tools[area->spacetype]) { - WM_toolsystem_refresh_screen_area(workspace, view_layer, area); - } - } } } } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 89f85caa729..5f684a752d8 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -854,7 +854,8 @@ wmWindow *WM_window_open(bContext *C, /* Set scene and view layer to match original window. */ STRNCPY(win->view_layer_name, view_layer->name); if (WM_window_get_active_scene(win) != scene) { - ED_screen_scene_change(C, win, scene); + /* No need to refresh the tool-system as the window has not yet finished being setup. */ + ED_screen_scene_change(C, win, scene, false); } screen->temp = temp; @@ -2271,13 +2272,13 @@ void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene * /* Set scene in parent and its child windows. */ if (win_parent->scene != scene) { - ED_screen_scene_change(C, win_parent, scene); + ED_screen_scene_change(C, win_parent, scene, true); changed = true; } LISTBASE_FOREACH (wmWindow *, win_child, &wm->windows) { if (win_child->parent == win_parent && win_child->scene != scene) { - ED_screen_scene_change(C, win_child, scene); + ED_screen_scene_change(C, win_child, scene, true); changed = true; } } |