[Bf-blender-cvs] [47bf779] master: Fix T40411: UI incorrectly permits changing materal_slots on linked obdata

Campbell Barton noreply at git.blender.org
Thu May 29 08:21:35 CEST 2014


Commit: 47bf77951a69d1b817f5201525e62e9e496f1359
Author: Campbell Barton
Date:   Thu May 29 16:16:31 2014 +1000
https://developer.blender.org/rB47bf77951a69d1b817f5201525e62e9e496f1359

Fix T40411: UI incorrectly permits changing materal_slots on linked obdata

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

M	source/blender/makesrna/intern/rna_object.c

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

diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 3807329..5d10a0a 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -710,6 +710,22 @@ static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
 	assign_material(ob, value.data, ob->actcol, BKE_MAT_ASSIGN_USERPREF);
 }
 
+static int rna_Object_active_material_editable(PointerRNA *ptr)
+{
+	Object *ob = (Object *)ptr->id.data;
+	bool is_editable;
+
+	if ((ob->matbits == NULL) || (ob->actcol == 0) || ob->matbits[ob->actcol - 1]) {
+		is_editable = (ob->id.lib == NULL);
+	}
+	else {
+		is_editable = ob->data ? (((ID *)ob->data)->lib == NULL) : false;
+	}
+
+	return is_editable ? PROP_EDITABLE : 0;
+}
+
+
 static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max,
                                                           int *UNUSED(softmin), int *UNUSED(softmax))
 {
@@ -2252,6 +2268,7 @@ static void rna_def_object(BlenderRNA *brna)
 	RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get",
 	                               "rna_Object_active_material_set", NULL, NULL);
 	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_editable_func(prop, "rna_Object_active_material_editable");
 	RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
 	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");




More information about the Bf-blender-cvs mailing list