From 6dbf2ccf55ed3e686dc4dbb7ebd9f4a99c0c9ff0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Sep 2006 14:52:59 +0000 Subject: [PATCH] bug of mine fixed didnt chech that a material existed before accessing it- crashed with null materials and mesh.getFromObject() --- source/blender/python/api2_2x/Mesh.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index 5e89705cf5a..7aed521c504 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -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<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++; } } }