diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-05-18 10:14:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-05-18 10:14:17 +0300 |
commit | 815ffaa6c1e5e4bb5aad1843c8d710a7f0ca9f4c (patch) | |
tree | d5080e6be7d5ca0a731bca463cfd467cb23c1ae7 /source/blender | |
parent | 218579fa53e68aebad53bf13b01e0cd491d135fd (diff) | |
parent | ff144edd8c20645f8064035d7257d637d0ff333e (diff) |
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 690c63a2cbf..0748458be03 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1466,20 +1466,35 @@ static const EnumPropertyItem *object_mode_set_itemsf(bContext *C, return item; } +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); + } +} + 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->mode; + eObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT; 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->type == OB_GPENCIL) && (mode == OB_MODE_EDIT)) { + if ((ob != NULL) && (ob->type == OB_GPENCIL) && (mode == OB_MODE_EDIT)) { mode = OB_MODE_EDIT_GPENCIL; } - if (!ED_object_mode_compat_test(ob, mode)) { + if (!ob || !ED_object_mode_compat_test(ob, mode)) { return OPERATOR_PASS_THROUGH; } @@ -1516,7 +1531,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) } /* if type is OB_GPENCIL, set cursor mode */ - if (ob->type == OB_GPENCIL) { + if ((ob) && (ob->type == OB_GPENCIL)) { if (ob->data) { bGPdata *gpd = (bGPdata *)ob->data; ED_gpencil_setup_modes(C, gpd, ob->mode); @@ -1551,7 +1566,8 @@ void OBJECT_OT_mode_set(wmOperatorType *ot) /* api callbacks */ ot->exec = object_mode_set_exec; - ot->poll = ED_operator_object_active_editable; + + ot->poll = object_mode_set_poll; // ED_operator_object_active_editable; /* flags */ ot->flag = 0; /* no register/undo here, leave it to operators being called */ |