Fix T52953: Crash removing material

This commit is contained in:
Campbell Barton 2018-01-04 21:35:09 +11:00
parent 457dc8d12c
commit 0becc8a7dd
Notes: blender-bot 2023-02-14 06:37:09 +01:00
Referenced by issue #53683, 2.79a release
Referenced by issue #52953, Crash when removing second material slot from data-linked objects
1 changed files with 6 additions and 6 deletions

View File

@ -1207,7 +1207,6 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime)
bool BKE_object_material_slot_remove(Object *ob)
{
Material *mao, ***matarar;
Object *obt;
short *totcolp;
short a, actcol;
@ -1255,11 +1254,13 @@ bool BKE_object_material_slot_remove(Object *ob)
}
actcol = ob->actcol;
obt = G.main->object.first;
while (obt) {
for (Object *obt = G.main->object.first; obt; obt = obt->id.next) {
if (obt->data == ob->data) {
/* Can happen when object material lists are used, see: T52953 */
if (actcol > obt->totcol) {
continue;
}
/* WATCH IT: do not use actcol from ob or from obt (can become zero) */
mao = obt->mat[actcol - 1];
if (mao)
@ -1279,7 +1280,6 @@ bool BKE_object_material_slot_remove(Object *ob)
obt->matbits = NULL;
}
}
obt = obt->id.next;
}
/* check indices from mesh */