Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-03-02 16:19:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-03-02 16:23:02 +0300
commitf9f559a05fc16e66031210e62bd7bc51d26208a3 (patch)
treeca121db88fc0c7898ca1fa46ca2c5907a0a465c0 /source/blender/editors/screen/workspace_edit.c
parent35bd1bb957b3c7491875d58d0092eab39c3b4e0e (diff)
WorkSpace: Simplify exiting mode after changes
It was too tricky to know ahead of time if an object would still be visible in the new window/workspace/scene/layer combination, especially since other windows may share some of these data-blocks. So store the context, make the change, then check if the object is still visible, freeing mode data of it's not.
Diffstat (limited to 'source/blender/editors/screen/workspace_edit.c')
-rw-r--r--source/blender/editors/screen/workspace_edit.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 23715f667fe..864cbbf5b05 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -171,10 +171,14 @@ bool ED_workspace_change(
if (screen_new) {
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);
ViewLayer *view_layer_old = BKE_workspace_view_layer_get(workspace_old, scene);
- ViewLayer *view_layer_new = BKE_workspace_view_layer_get(workspace_new, scene);
Object *obact_old = OBACT(view_layer_old);
+
+ ViewLayer *view_layer_new = BKE_workspace_view_layer_get(workspace_new, scene);
Object *obact_new = OBACT(view_layer_new);
/* Handle object mode switching */
@@ -187,27 +191,11 @@ bool ED_workspace_change(
/* pass */
}
else {
- if (workspace_old->object_mode & OB_MODE_ALL_MODE_DATA) {
- if (obact_old) {
- bool obact_old_is_active =
- ED_workspace_object_mode_in_other_window(bmain->wm.first, win, obact_old, NULL);
- if (obact_old_is_active == false) {
- eObjectMode object_mode = workspace_old->object_mode;
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
- ED_object_mode_generic_exit(&eval_ctx, workspace_old, scene, obact_old);
- /* weak, set it back so it's used when activating again. */
- workspace_old->object_mode = object_mode;
- }
- }
- }
-
- if (workspace_new->object_mode != OB_MODE_OBJECT) {
- use_object_mode = true;
- }
+ use_object_mode = true;
}
}
+
WM_window_set_active_layout(win, workspace_new, layout_new);
WM_window_set_active_workspace(win, workspace_new);
@@ -222,6 +210,10 @@ bool ED_workspace_change(
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;
+ ED_object_mode_generic_exit_or_other_window(&eval_ctx_old, bmain->wm.first, workspace_old, scene, obact_old);
+ workspace_old->object_mode = object_mode;
ED_object_mode_generic_enter_or_other_window(C, workspace_new->object_mode);
}
else {