Fix T60714: Avoid creation of nested objects

In grease pencil is not logic add an object inside other object in edit mode. The object must be created only in Object mode.
This commit is contained in:
Antonio Vazquez 2019-01-21 18:29:02 +01:00
parent 0af8ad51c0
commit 48149459e4
Notes: blender-bot 2023-02-14 10:35:28 +01:00
Referenced by issue #60714, Nested grease pencil , becomes uneditable after nested and deleted
1 changed files with 18 additions and 1 deletions

View File

@ -967,6 +967,23 @@ void OBJECT_OT_drop_named_image(wmOperatorType *ot)
}
/********************* Add Gpencil Operator ********************/
bool object_gpencil_add_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
if ((scene == NULL) || (ID_IS_LINKED(scene))) {
return false;
}
if (obact && obact->type == OB_GPENCIL) {
if (obact->mode != OB_MODE_OBJECT) {
return false;
}
}
return true;
}
static int object_gpencil_add_exec(bContext *C, wmOperator *op)
{
@ -1073,7 +1090,7 @@ void OBJECT_OT_gpencil_add(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = object_gpencil_add_exec;
ot->poll = ED_operator_scene_editable;
ot->poll = object_gpencil_add_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;