forked from bartvdbraak/blender
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).
This commit is contained in:
parent
cffd10a7c8
commit
7b938abe2b
@ -628,11 +628,14 @@ Material *give_current_material(Object *ob, short act)
|
|||||||
if (totcolp == NULL || ob->totcol == 0) return NULL;
|
if (totcolp == NULL || ob->totcol == 0) return NULL;
|
||||||
|
|
||||||
if (act < 0) {
|
if (act < 0) {
|
||||||
printf("no!\n");
|
printf("Negative material index!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (act > ob->totcol) act = ob->totcol;
|
/* return NULL for invalid 'act', can happen for mesh face indices */
|
||||||
else if (act <= 0) act = 1;
|
if (act > ob->totcol)
|
||||||
|
return NULL;
|
||||||
|
else if (act <= 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (ob->matbits && ob->matbits[act - 1]) { /* in object */
|
if (ob->matbits && ob->matbits[act - 1]) { /* in object */
|
||||||
ma = ob->mat[act - 1];
|
ma = ob->mat[act - 1];
|
||||||
@ -1234,6 +1237,11 @@ int object_remove_material_slot(Object *ob)
|
|||||||
|
|
||||||
if (*matarar == NULL) return FALSE;
|
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 */
|
/* we delete the actcol */
|
||||||
mao = (*matarar)[ob->actcol - 1];
|
mao = (*matarar)[ob->actcol - 1];
|
||||||
if (mao) mao->id.us--;
|
if (mao) mao->id.us--;
|
||||||
|
Loading…
Reference in New Issue
Block a user