bug of mine fixed
authorCampbell Barton <ideasman42@gmail.com>
Fri, 15 Sep 2006 14:52:59 +0000 (14:52 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 15 Sep 2006 14:52:59 +0000 (14:52 +0000)
didnt chech that a material existed before accessing it- crashed with null materials and mesh.getFromObject()

source/blender/python/api2_2x/Mesh.c

index 5e89705cf5a3b59d3c5aee2408ed088501d46d9c..7aed521c504c6f25c54dcfeeeddf766f5676c31c 100644 (file)
@@ -5763,11 +5763,16 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args )
                                        /* are we an object material or data based? */
                                        if (ob->colbits & 1<<i) {
                                                self->mesh->mat[i] = ob->mat[i];
-                                               ob->mat[i]->id.us++;
-                                               origmesh->mat[i]->id.us--;
+                                               
+                                               if (ob->mat[i])
+                                                       ob->mat[i]->id.us++;
+                                               if (origmesh->mat[i])
+                                                       origmesh->mat[i]->id.us--;
                                        } else {
-                                               origmesh->mat[i]->id.us++;
                                                self->mesh->mat[i] = origmesh->mat[i];
+                                               
+                                               if (origmesh->mat[i])
+                                                       origmesh->mat[i]->id.us++;
                                        }
                                }
                        }