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
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2012-12-26 21:36:51 +0400
committerTon Roosendaal <ton@blender.org>2012-12-26 21:36:51 +0400
commit7b938abe2b85eae1fdfe8d584935f4ec4d94f297 (patch)
tree9d6fa3d68290fdc10eb00d4a2e80e62fc63424b2 /source
parentcffd10a7c8569c7ca6edf171b3a542dcbec628af (diff)
Bugfix #33667
Mesh had invalid face indices (number too high). On Separate in Edit Mode it crashed. Two fixes: - The Material properties viewer just showed the last material in the index array. Now it shows nothing, to indicate it's an invalid selected material. - Crash was caused by array copy magic, not checking the active index properly. (No assert, no warning prints, I think cases like this can happen too easily, and this way user gets notified nicely and can fix it).
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/material.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index f0327719372..bf64bd3d093 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -628,11 +628,14 @@ Material *give_current_material(Object *ob, short act)
if (totcolp == NULL || ob->totcol == 0) return NULL;
if (act < 0) {
- printf("no!\n");
+ printf("Negative material index!\n");
}
- if (act > ob->totcol) act = ob->totcol;
- else if (act <= 0) act = 1;
+ /* return NULL for invalid 'act', can happen for mesh face indices */
+ if (act > ob->totcol)
+ return NULL;
+ else if (act <= 0)
+ return NULL;
if (ob->matbits && ob->matbits[act - 1]) { /* in object */
ma = ob->mat[act - 1];
@@ -1234,6 +1237,11 @@ int object_remove_material_slot(Object *ob)
if (*matarar == NULL) return FALSE;
+ /* can happen on face selection in editmode */
+ if (ob->actcol > ob->totcol) {
+ ob->actcol = ob->totcol;
+ }
+
/* we delete the actcol */
mao = (*matarar)[ob->actcol - 1];
if (mao) mao->id.us--;