Fixed a python segfault when linking a new object to a scene that had no data and was a Surf. the data wasnt created and blender died. Now an error is raised instead.

This commit is contained in:
2005-12-29 12:06:42 +00:00
parent b73748bdd0
commit ccf117376d
2 changed files with 17 additions and 5 deletions

View File

@@ -946,7 +946,8 @@ int EXPP_add_obdata( struct Object *object )
object->data = add_mball( );
break;
/* TODO the following types will be supported later
/* TODO the following types will be supported later,
be sure to update Scene_link when new types are supported
case OB_SURF:
object->data = add_curve(OB_SURF);
G.totcurve++;

View File

@@ -742,9 +742,19 @@ static PyObject *Scene_link( BPy_Scene * self, PyObject * args )
if( !PyArg_ParseTuple( args, "O!", &Object_Type, &bpy_obj ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected Object argument" );
else { /* Ok, all is fine, let's try to link it */
Object *object = bpy_obj->object;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Could not create data on demand for this object type!" );
Object *object = bpy_obj->object;
/* Object.c's EXPP_add_obdata does not support these objects */
if (!object->data && (object->type == OB_SURF || object->type == OB_FONT || object->type == OB_WAVE )) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Object has no data and new data cant be automaticaly created for Surf, Text or Wave type objects!" );
} else {
/* Ok, all is fine, let's try to link it */
Base *base;
/* We need to link the object to a 'Base', then link this base
@@ -766,8 +776,9 @@ static PyObject *Scene_link( BPy_Scene * self, PyObject * args )
"couldn't allocate new Base for object" );
/* check if this object has obdata, case not, try to create it */
if( !object->data && ( object->type != OB_EMPTY ) )
EXPP_add_obdata( object ); /* returns -1 on error, defined in Object.c */
EXPP_add_obdata( object ); /* returns -1 on error, defined in Object.c */
base->object = object; /* link object to the new base */
base->lay = object->lay;