Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2019-08-16 15:36:57 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-08-16 15:36:57 +0300
commitc70f975d5c3b961e0c77eba3a35c8a892f39214d (patch)
tree04dc64117f78b16f9e6aa47f040edfe9ad6677a2 /source/blender/blenkernel/intern/material.c
parent82e719ff8764da6c48ba3de4e5c11226953002e8 (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/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index b01c1189fd1..1545ae4f48f 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -461,7 +461,7 @@ void BKE_material_append_id(Main *bmain, ID *id, Material *ma)
}
}
-Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i, bool update_data)
+Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i)
{
short index = (short)index_i;
Material *ret = NULL;
@@ -489,10 +489,7 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i, bool update_data
test_all_objects_materials(bmain, id);
}
- if (update_data) {
- /* decrease mat_nr index */
- material_data_index_remove_id(id, index);
- }
+ material_data_index_remove_id(id, index);
DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
@@ -502,7 +499,7 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i, bool update_data
return ret;
}
-void BKE_material_clear_id(Main *bmain, ID *id, bool update_data)
+void BKE_material_clear_id(Main *bmain, ID *id)
{
Material ***matar;
if ((matar = give_matarar_id(id))) {
@@ -516,12 +513,9 @@ void BKE_material_clear_id(Main *bmain, ID *id, bool update_data)
MEM_freeN(*matar);
*matar = NULL;
}
- test_all_objects_materials(bmain, id);
- if (update_data) {
- /* decrease mat_nr index */
- material_data_index_clear_id(id);
- }
+ test_all_objects_materials(bmain, id);
+ material_data_index_clear_id(id);
DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);