diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2018-03-21 01:31:44 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2018-03-21 01:31:44 +0300 |
commit | 7701f9e35c524fb3fb4ba9164b701dfcca7f80ec (patch) | |
tree | a0a6c6239f948aafe991c8c1ff124fb58bd43392 /source | |
parent | 89aa4b160406eda3a55140254caedda598b2e686 (diff) |
Fix crash when changing workspaces
Steps to reproduce were:
* Append a workspace (via '+' icon) - make sure its from the default workspaces.blend
* Activate it
* Should crash
Was accessing data from view-layer which wasn't updated yet (and thus could be
NULL). Crash occured after rB8153f89518b4a.
@campbellbarton, you may want to check if all object-mode stuff still works as
expected, not sure what's the state of it.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/screen/workspace_edit.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 2b28f61f901..bf2e788e2b0 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -169,12 +169,27 @@ bool ED_workspace_change( BLI_assert(BKE_workspace_layout_screen_get(layout_new) == screen_new); if (screen_new) { + Scene *scene = WM_window_get_active_scene(win); bool use_object_mode = false; /* Store old context for exiting edit-mode. */ EvaluationContext eval_ctx_old; CTX_data_eval_ctx(C, &eval_ctx_old); - Scene *scene = WM_window_get_active_scene(win); + + + WM_window_set_active_layout(win, workspace_new, layout_new); + WM_window_set_active_workspace(win, workspace_new); + + /* update screen *after* changing workspace - which also causes the actual screen change */ + screen_change_update(C, win, screen_new); + workspace_change_update(workspace_new, workspace_old, C); + + BLI_assert(BKE_workspace_view_layer_get(workspace_new, CTX_data_scene(C)) != NULL); + BLI_assert(CTX_wm_workspace(C) == workspace_new); + + WM_toolsystem_unlink(C, workspace_old); + WM_toolsystem_link(C, workspace_new); + ViewLayer *view_layer_old = BKE_workspace_view_layer_get(workspace_old, scene); Object *obact_old = OBACT(view_layer_old); @@ -195,20 +210,6 @@ bool ED_workspace_change( } } - - WM_window_set_active_layout(win, workspace_new, layout_new); - WM_window_set_active_workspace(win, workspace_new); - - /* update screen *after* changing workspace - which also causes the actual screen change */ - screen_change_update(C, win, screen_new); - workspace_change_update(workspace_new, workspace_old, C); - - BLI_assert(BKE_workspace_view_layer_get(workspace_new, CTX_data_scene(C)) != NULL); - BLI_assert(CTX_wm_workspace(C) == workspace_new); - - WM_toolsystem_unlink(C, workspace_old); - WM_toolsystem_link(C, workspace_new); - if (use_object_mode) { /* weak, set it back so it's used when activating again. */ eObjectMode object_mode = workspace_old->object_mode; |