[Bf-blender-cvs] [48149459e46] master: Fix T60714: Avoid creation of nested objects

Antonioya noreply at git.blender.org
Mon Jan 21 18:29:11 CET 2019


Commit: 48149459e46fb45b51680e937962b28045623932
Author: Antonioya
Date:   Mon Jan 21 18:29:02 2019 +0100
Branches: master
https://developer.blender.org/rB48149459e46fb45b51680e937962b28045623932

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.

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

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 918b3500a08..56697f41ec0 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -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;



More information about the Bf-blender-cvs mailing list