diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-05-18 10:14:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-05-18 10:14:24 +0300 |
commit | fd8d2ceafe1004b7c3ade91535ca4743d21b97ce (patch) | |
tree | 16050133f25402a8d206bc1a1bafeb083600b8ad /source/blender | |
parent | 815ffaa6c1e5e4bb5aad1843c8d710a7f0ca9f4c (diff) | |
parent | 2a3797b1091d65dac352ebb37f4ec58dde703397 (diff) |
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 25 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 9 |
3 files changed, 16 insertions, 19 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 43f3a578bfe..bc6a4b23609 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -347,6 +347,7 @@ bool ED_operator_info_active(struct bContext *C); bool ED_operator_console_active(struct bContext *C); bool ED_operator_object_active(struct bContext *C); +bool ED_operator_object_active_editable_ex(struct bContext *C, const Object *ob); bool ED_operator_object_active_editable(struct bContext *C); bool ED_operator_object_active_editable_mesh(struct bContext *C); bool ED_operator_object_active_editable_font(struct bContext *C); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0748458be03..53a557c5871 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1468,17 +1468,9 @@ static const EnumPropertyItem *object_mode_set_itemsf(bContext *C, static bool object_mode_set_poll(bContext *C) { - /* Since Grease Pencil editmode is also handled here, - * we have a special exception for allowing this operator - * to still work in that case when there's no active object - * so that users can exit editmode this way as per normal. - */ - if (ED_operator_object_active_editable(C)) { - return true; - } - else { - return (CTX_data_gpencil_data(C) != NULL); - } + /* Needed as #ED_operator_object_active_editable doesn't call use 'active_object'. */ + Object *ob = CTX_data_active_object(C); + return ED_operator_object_active_editable_ex(C, ob); } static int object_mode_set_exec(bContext *C, wmOperator *op) @@ -1486,15 +1478,15 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) bool use_submode = STREQ(op->idname, "OBJECT_OT_mode_set_with_submode"); Object *ob = CTX_data_active_object(C); eObjectMode mode = RNA_enum_get(op->ptr, "mode"); - eObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT; + eObjectMode restore_mode = ob->mode; const bool toggle = RNA_boolean_get(op->ptr, "toggle"); /* by default the operator assume is a mesh, but if gp object change mode */ - if ((ob != NULL) && (ob->type == OB_GPENCIL) && (mode == OB_MODE_EDIT)) { + if ((ob->type == OB_GPENCIL) && (mode == OB_MODE_EDIT)) { mode = OB_MODE_EDIT_GPENCIL; } - if (!ob || !ED_object_mode_compat_test(ob, mode)) { + if (!ED_object_mode_compat_test(ob, mode)) { return OPERATOR_PASS_THROUGH; } @@ -1531,7 +1523,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) } /* if type is OB_GPENCIL, set cursor mode */ - if ((ob) && (ob->type == OB_GPENCIL)) { + if (ob->type == OB_GPENCIL) { if (ob->data) { bGPdata *gpd = (bGPdata *)ob->data; ED_gpencil_setup_modes(C, gpd, ob->mode); @@ -1566,8 +1558,7 @@ void OBJECT_OT_mode_set(wmOperatorType *ot) /* api callbacks */ ot->exec = object_mode_set_exec; - - ot->poll = object_mode_set_poll; // ED_operator_object_active_editable; + ot->poll = object_mode_set_poll; /* flags */ ot->flag = 0; /* no register/undo here, leave it to operators being called */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 5b808206935..10ba4580958 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -339,7 +339,7 @@ bool ED_operator_console_active(bContext *C) return ed_spacetype_test(C, SPACE_CONSOLE); } -static bool ed_object_hidden(Object *ob) +static bool ed_object_hidden(const Object *ob) { /* if hidden but in edit mode, we still display, can happen with animation */ return ((ob->restrictflag & OB_RESTRICT_VIEWPORT) && !(ob->mode & OB_MODE_EDIT)); @@ -351,10 +351,15 @@ bool ED_operator_object_active(bContext *C) return ((ob != NULL) && !ed_object_hidden(ob)); } +bool ED_operator_object_active_editable_ex(bContext *C, const Object *ob) +{ + return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob)); +} + bool ED_operator_object_active_editable(bContext *C) { Object *ob = ED_object_active_context(C); - return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob)); + return ED_operator_object_active_editable_ex(C, ob); } bool ED_operator_object_active_editable_mesh(bContext *C) |