Fix T40411: UI incorrectly permits changing materal_slots on linked obdata
authorCampbell Barton <ideasman42@gmail.com>
Thu, 29 May 2014 06:16:31 +0000 (16:16 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 29 May 2014 06:21:15 +0000 (16:21 +1000)
source/blender/makesrna/intern/rna_object.c

index 38073293df8e1597789b067b5e9998aa3892312a..5d10a0a61c1783c862c2c0d8523c7aba55efe043 100644 (file)
@@ -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");