fix for a crash in Blender.Mesh,

getting curve data from an object failed (with only 1 curve vertex)
Blender.Mesh didnt check this and crashed.
This commit is contained in:
2007-05-28 16:49:48 +00:00
parent 3030e93a5b
commit a8bc1f3397
3 changed files with 12 additions and 3 deletions

View File

@@ -808,6 +808,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me)
}
}
/* this may fail replacing ob->data, be sure to check ob->type */
void nurbs_to_mesh(Object *ob)
{
Object *ob1;
@@ -847,7 +848,8 @@ void nurbs_to_mesh(Object *ob)
dl= dl->next;
}
if(totvert==0) {
error("can't convert");
/* error("can't convert"); */
/* Make Sure you check ob->data is a curve */
return;
}

View File

@@ -5704,6 +5704,10 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args )
nurbs_to_mesh( tmpobj );
tmpmesh = tmpobj->data;
free_libblock_us( &G.main->object, tmpobj );
if (ob->type != OB_MESH)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"cant convert curve to mesh. Does the curve have any segments?" );
break;
case OB_MBALL:
/* metaballs don't have modifiers, so just convert to mesh */

View File

@@ -2527,9 +2527,12 @@ static void curvetomesh(Object *ob)
if(dl==0) makeDispListCurveTypes(ob, 0); /* force creation */
nurbs_to_mesh(ob); /* also does users */
if (ob->type != OB_MESH) {
error("can't convert curve to mesh");
} else {
object_free_modifiers(ob);
}
}
void convertmenu(void)
{