diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-05-13 16:04:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-05-13 16:14:01 +0300 |
commit | 5159b8e1eadb3803064a97874f7ebc059ce2be32 (patch) | |
tree | 101bf4a553a7da3a2f0979db9416635d132f706e /source/blender/editors/object | |
parent | 54ea3562406c633dc69f59697cca3cd1cded3bcd (diff) |
Fix extra undo step when switching object modes
Changing between modes would always add a user visible undo step
that set object mode.
Avoid storing this extra undo step on object mode switching.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 6929930c26c..ab82f3c3f04 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1408,28 +1408,34 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; } - if (ob->mode != mode) { - /* we should be able to remove this call, each operator calls */ - ED_object_mode_compat_set(C, ob, mode, op->reports); - } - - /* Exit current mode if it's not the mode we're setting */ - if (mode != OB_MODE_OBJECT && (ob->mode != mode || toggle)) { - /* Enter new mode */ - ED_object_mode_toggle(C, mode); + if (toggle == false) { + if (ob->mode != mode) { + if (mode != OB_MODE_OBJECT) { + /* Enter new mode. */ + ED_object_mode_toggle(C, mode); + } + else { + ED_object_mode_compat_set(C, ob, mode, op->reports); + } + } } + else { + /* Exit current mode if it's not the mode we're setting */ + if (mode != OB_MODE_OBJECT) { + /* Enter new mode. */ + ED_object_mode_toggle(C, mode); + } - if (toggle) { /* Special case for Object mode! */ - if (mode == OB_MODE_OBJECT && restore_mode == OB_MODE_OBJECT && - ob->restore_mode != OB_MODE_OBJECT) { + if ((mode == OB_MODE_OBJECT) && (restore_mode == OB_MODE_OBJECT) && + (ob->restore_mode != OB_MODE_OBJECT)) { ED_object_mode_toggle(C, ob->restore_mode); } else if (ob->mode == mode) { /* For toggling, store old mode so we know what to go back to */ ob->restore_mode = restore_mode; } - else if (ob->restore_mode != OB_MODE_OBJECT && ob->restore_mode != mode) { + else if ((ob->restore_mode != OB_MODE_OBJECT) && (ob->restore_mode != mode)) { ED_object_mode_toggle(C, ob->restore_mode); } } |