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:
Ton Roosendaal 2012-12-26 17:36:51 +00:00
parent cffd10a7c8
commit 7b938abe2b
1 changed files with 11 additions and 3 deletions

View File

@ -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--;