diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2019-08-16 15:36:57 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2019-08-16 15:36:57 +0300 |
commit | c70f975d5c3b961e0c77eba3a35c8a892f39214d (patch) | |
tree | 04dc64117f78b16f9e6aa47f040edfe9ad6677a2 /source/blender/makesrna | |
parent | 82e719ff8764da6c48ba3de4e5c11226953002e8 (diff) |
Fix T67999: calling Mesh.materials.clear() crashes Blender
The `BKE_material_pop_id()` and `BKE_material_clear_id()` functions had
a parameter `update_data` that, when `false`, would cause the mesh polys
to keep their material index, even when the indexed material slots were
removed. This behaviour was never used in the C code and not supported
by the drawing code, making polygons disappear and causing crashes. The
Python binding in RNA, however, defaulted to `update_data=False`.
This commit removes the `update_data` parameter altogether, and makes
the functions always fix up the material indices.
Reviewed by: mont29, brecht
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 57cdbbadeb8..7996750a1b8 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -642,8 +642,7 @@ static void rna_IDMaterials_append_id(ID *id, Main *bmain, Material *ma) WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id); } -static Material *rna_IDMaterials_pop_id( - ID *id, Main *bmain, ReportList *reports, int index_i, bool remove_material_slot) +static Material *rna_IDMaterials_pop_id(ID *id, Main *bmain, ReportList *reports, int index_i) { Material *ma; short *totcol = give_totcolp_id(id); @@ -657,7 +656,7 @@ static Material *rna_IDMaterials_pop_id( return NULL; } - ma = BKE_material_pop_id(bmain, id, index_i, remove_material_slot); + ma = BKE_material_pop_id(bmain, id, index_i); if (*totcol == totcol_orig) { BKE_report(reports, RPT_ERROR, "No material to removed"); @@ -671,9 +670,9 @@ static Material *rna_IDMaterials_pop_id( return ma; } -static void rna_IDMaterials_clear_id(ID *id, Main *bmain, bool remove_material_slot) +static void rna_IDMaterials_clear_id(ID *id, Main *bmain) { - BKE_material_clear_id(bmain, id, remove_material_slot); + BKE_material_clear_id(bmain, id); DEG_id_tag_update(id, ID_RECALC_GEOMETRY); WM_main_add_notifier(NC_OBJECT | ND_DRAW, id); @@ -1116,16 +1115,12 @@ static void rna_def_ID_materials(BlenderRNA *brna) RNA_def_function_ui_description(func, "Remove a material from the data-block"); parm = RNA_def_int( func, "index", -1, -MAXMAT, MAXMAT, "", "Index of material to remove", 0, MAXMAT); - RNA_def_boolean( - func, "update_data", 0, "", "Update data by re-adjusting the material slots assigned"); parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "clear", "rna_IDMaterials_clear_id"); RNA_def_function_flag(func, FUNC_USE_MAIN); RNA_def_function_ui_description(func, "Remove all materials from the data-block"); - RNA_def_boolean( - func, "update_data", 0, "", "Update data by re-adjusting the material slots assigned"); } static void rna_def_image_preview(BlenderRNA *brna) |