Fix crash in active_paint_texture_index callback

This commit is contained in:
Campbell Barton 2014-09-10 21:56:45 +10:00
parent 20d6b792a4
commit 64e955f522
Notes: blender-bot 2023-12-19 15:47:29 +01:00
Referenced by pull request #116345, Fix #116325: crash assigning non-valid `material.paint_active_slot`
Referenced by commit 85bf6814c7, Fix #116325: crash assigning non-valid `material.paint_active_slot`
1 changed files with 11 additions and 8 deletions

View File

@ -195,14 +195,17 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s
nodeSetActive(ma->nodetree, node);
}
for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
ED_space_image_set(sima, scene, scene->obedit, ma->texpaintslot[ma->paint_active_slot].ima);
if (ma->texpaintslot) {
Image *image = ma->texpaintslot[ma->paint_active_slot].ima;
for (sc = bmain->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
ED_space_image_set(sima, scene, scene->obedit, image);
}
}
}
}