diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-05-29 10:16:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-05-29 10:21:15 +0400 |
commit | 47bf77951a69d1b817f5201525e62e9e496f1359 (patch) | |
tree | cd74f06093af138fff75191bfc406cf8732385b9 /source | |
parent | a366acbe618522bb02b023d32232c089c5726892 (diff) |
Fix T40411: UI incorrectly permits changing materal_slots on linked obdata
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 38073293df8..5d10a0a61c1 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"); |