Fix #33975: Crash when reloading texture
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 24 Jan 2013 08:49:48 +0000 (08:49 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 24 Jan 2013 08:49:48 +0000 (08:49 +0000)
Two issues in texture_changed:
- Missing NULL check for material (slot could be empty)
- Materials could be linked to object, added special check for this

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