[Bf-blender-cvs] [80450331c7c] master: Fix T86884: Don't remove the "line art object add" enum item

Sebastian Parborg noreply at git.blender.org
Wed Mar 24 16:23:37 CET 2021


Commit: 80450331c7cc015f471dbafc3c783fafd1707cf5
Author: Sebastian Parborg
Date:   Wed Mar 24 16:17:59 2021 +0100
Branches: master
https://developer.blender.org/rB80450331c7cc015f471dbafc3c783fafd1707cf5

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.

===================================================================

M	source/blender/editors/object/object_add.c

===================================================================

diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index e4527740164..b3fb497aa9a 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -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]);
   }



More information about the Bf-blender-cvs mailing list