Fix T86884: Don't remove the "line art object add" enum item

We would not add the "object line art" enum to the operator enum list,
if there were no active object in the scene.

This would make it impossible to call this operator from python code as
the enum would we hidden when we were not in a viewport context.

Always make the operator available, having no active object is not a
strict requirement for the operator to work, so expose it always.
This commit is contained in:
Sebastian Parborg 2021-03-24 16:17:59 +01:00
parent 8060293656
commit 80450331c7
Notes: blender-bot 2023-02-14 10:43:47 +01:00
Referenced by issue #86884, Grease Pencil Object Line Art type='<UNKNOWN ENUM>'
1 changed files with 4 additions and 13 deletions

View File

@ -1440,7 +1440,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static const EnumPropertyItem *object_gpencil_add_options(bContext *C,
static const EnumPropertyItem *object_gpencil_add_options(bContext *UNUSED(C),
PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
@ -1453,18 +1453,9 @@ static const EnumPropertyItem *object_gpencil_add_options(bContext *C,
/* Default types. */
for (i = 0; i < orig_count; i++) {
if (item_ref[i].value == GP_LRT_OBJECT || item_ref[i].value == GP_LRT_COLLECTION ||
item_ref[i].value == GP_LRT_SCENE) {
if (item_ref[i].value == GP_LRT_SCENE) {
/* separator before line art types */
RNA_enum_item_add_separator(&item, &totitem);
}
else if (item_ref[i].value == GP_LRT_OBJECT) {
Object *ob = CTX_data_active_object(C);
if (!ob || ob->type != OB_MESH) {
continue;
}
}
if (item_ref[i].value == GP_LRT_SCENE) {
/* separator before line art types */
RNA_enum_item_add_separator(&item, &totitem);
}
RNA_enum_item_add(&item, &totitem, &item_ref[i]);
}