[Bf-blender-cvs] [828710d] master: Fix T45782: bpy.ops.object.select_by_layer match='SHARED' option is not working.

Bastien Montagne noreply at git.blender.org
Thu Aug 13 13:19:43 CEST 2015


Commit: 828710d2aca3c7595789d9892e092593e9d64e66
Author: Bastien Montagne
Date:   Thu Aug 13 13:18:45 2015 +0200
Branches: master
https://developer.blender.org/rB828710d2aca3c7595789d9892e092593e9d64e66

Fix T45782: bpy.ops.object.select_by_layer match='SHARED' option is not working.

Looks like some half-done change from enum to bool (or vice-versa), that op was just broken!

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

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

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

diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 65ce0c8..6e00875 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -929,11 +929,16 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot)
 }
 
 /************************* Select by Layer **********************/
+enum {
+	OB_SEL_LAYERMATCH_EXACT = 1,
+	OB_SEL_LAYERMATCH_SHARED = 2,
+};
 
 static int object_select_by_layer_exec(bContext *C, wmOperator *op)
 {
 	unsigned int layernum;
-	bool extend, match;
+	bool extend;
+	int match;
 	
 	extend = RNA_boolean_get(op->ptr, "extend");
 	layernum = RNA_int_get(op->ptr, "layers");
@@ -951,13 +956,20 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op)
 	{
 		bool ok = false;
 
-		if (match == true) /* exact */
-			ok = (base->lay == (1 << (layernum - 1)));
-		else /* shared layers */
-			ok = (base->lay & (1 << (layernum - 1))) != 0;
+		switch (match) {
+			case OB_SEL_LAYERMATCH_EXACT:
+				ok = (base->lay == (1 << (layernum - 1)));
+				break;
+			case OB_SEL_LAYERMATCH_SHARED:
+				ok = (base->lay & (1 << (layernum - 1))) != 0;
+				break;
+			default:
+				break;
+		}
 
-		if (ok)
+		if (ok) {
 			ED_base_object_select(base, BA_SELECT);
+		}
 	}
 	CTX_DATA_END;
 	
@@ -970,8 +982,8 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op)
 void OBJECT_OT_select_by_layer(wmOperatorType *ot)
 {
 	static EnumPropertyItem match_items[] = {
-		{1, "EXACT", 0, "Exact Match", ""},
-		{2, "SHARED", 0, "Shared Layers", ""},
+		{OB_SEL_LAYERMATCH_EXACT, "EXACT", 0, "Exact Match", ""},
+		{OB_SEL_LAYERMATCH_SHARED, "SHARED", 0, "Shared Layers", ""},
 		{0, NULL, 0, NULL, NULL}
 	};
 
@@ -989,7 +1001,7 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 	
 	/* properties */
-	RNA_def_enum(ot->srna, "match", match_items, 0, "Match", "");
+	RNA_def_enum(ot->srna, "match", match_items, OB_SEL_LAYERMATCH_EXACT, "Match", "");
 	RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
 	RNA_def_int(ot->srna, "layers", 1, 1, 20, "Layer", "", 1, 20);
 }




More information about the Bf-blender-cvs mailing list