Fix #33975: Crash when reloading texture
[blender.git] / source / blender / editors / render / render_update.c
index 38535eca918e8bc14f84669cf5cb462b010dad72..16d7923baff10d245ac41b15adf2e8c387833976 100644 (file)
@@ -394,7 +394,14 @@ static void texture_changed(Main *bmain, Tex *tex)
 
                        if (dm && totmaterial && material) {
                                for (a = 0; a < *totmaterial; a++) {
-                                       if (material_uses_texture((*material)[a], tex)) {
+                                       Material *ma;
+
+                                       if (ob->matbits && ob->matbits[a])
+                                               ma = ob->mat[a];
+                                       else
+                                               ma = (*material)[a];
+
+                                       if (ma && material_uses_texture(ma, tex)) {
                                                GPU_drawobject_free(dm);
                                                break;
                                        }