diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-03-01 13:07:09 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-03-01 13:33:06 +0300 |
commit | bcafdc82d83f70312859c9a045c92daa326afbdf (patch) | |
tree | a9112ab0cdb81548d756711ba2014ddbc539ee6b /source/blender/editors/object | |
parent | 7aed2de798b1e5f8663e8fe608a99f6c9f53c382 (diff) |
WorkSpace: fix mode exiting w/ multi-window
Activating an object exited modes for all other objects in the layer.
Now check these objects aren't active in other windows first.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 36 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 7 |
2 files changed, 40 insertions, 3 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index e975ee40c3c..320aadf2249 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2096,33 +2096,65 @@ bool ED_object_mode_generic_enter( * Use for changing works-paces or changing active object. * Caller can check #OB_MODE_ALL_MODE_DATA to test if this needs to be run. */ -void ED_object_mode_generic_exit( +static bool ed_object_mode_generic_exit_ex( const struct EvaluationContext *eval_ctx, - struct WorkSpace *workspace, struct Scene *scene, struct Object *ob) + struct WorkSpace *workspace, struct Scene *scene, struct Object *ob, + bool only_test) { if (eval_ctx->object_mode & OB_MODE_EDIT) { if (BKE_object_is_in_editmode(ob)) { + if (only_test) { + return true; + } ED_object_editmode_exit_ex(NULL, workspace, scene, ob, EM_FREEDATA); } } else if (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) { if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_VERTEX_PAINT)) { + if (only_test) { + return true; + } ED_object_vpaintmode_exit_ex(workspace, ob); } } else if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) { if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_WEIGHT_PAINT)) { + if (only_test) { + return true; + } ED_object_wpaintmode_exit_ex(workspace, ob); } } else if (eval_ctx->object_mode & OB_MODE_SCULPT) { if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_SCULPT)) { + if (only_test) { + return true; + } ED_object_sculptmode_exit_ex(eval_ctx, workspace, scene, ob); } } else { + if (only_test) { + return false; + } BLI_assert((eval_ctx->object_mode & OB_MODE_ALL_MODE_DATA) == 0); } + + return false; +} + +void ED_object_mode_generic_exit( + const struct EvaluationContext *eval_ctx, + struct WorkSpace *workspace, struct Scene *scene, struct Object *ob) +{ + ed_object_mode_generic_exit_ex(eval_ctx, workspace, scene, ob, false); +} + +bool ED_object_mode_generic_has_data( + const struct EvaluationContext *eval_ctx, + struct Object *ob) +{ + return ed_object_mode_generic_exit_ex(eval_ctx, NULL, NULL, ob, true); } bool ED_object_editmode_calc_active_center(Object *obedit, const bool select_only, float r_center[3]) diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 5cf04ddc735..9875fb84b56 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -157,11 +157,16 @@ void ED_object_base_activate(bContext *C, Base *base) * Not correct because it's possible other work-spaces use these. * although that's a corner case. */ if (workspace->object_mode & OB_MODE_ALL_MODE_DATA) { + wmWindowManager *wm = CTX_wm_manager(C); EvaluationContext eval_ctx; CTX_data_eval_ctx(C, &eval_ctx); FOREACH_OBJECT_BEGIN(view_layer, ob) { if (ob != obact) { - ED_object_mode_generic_exit(&eval_ctx, workspace, scene, ob); + if (ED_object_mode_generic_has_data(&eval_ctx, ob) && + ED_workspace_object_mode_in_other_window(wm, workspace, ob, NULL) == false) + { + ED_object_mode_generic_exit(&eval_ctx, workspace, scene, ob); + } } } FOREACH_OBJECT_END; |