replaced more M_Object_Get for the faster Object_CreatePyObject.

Object.GetSelected now dosnt return None if there is no 3d view. - wasnt documented and likely would mess up scripts that always expected a list. - Just return an empty list instead.
This commit is contained in:
2006-01-03 06:14:53 +00:00
parent fc079f8482
commit d14f6c9cbc
2 changed files with 18 additions and 27 deletions

View File

@@ -766,12 +766,13 @@ static PyObject *M_Object_GetSelected( PyObject * self )
PyObject *list;
Base *base_iter;
if( G.vd == NULL ) {
// No 3d view has been initialized yet, simply return None
Py_INCREF( Py_None );
return Py_None;
}
list = PyList_New( 0 );
if( G.vd == NULL ) {
/* No 3d view has been initialized yet, simply return an empty list */
return list;
}
if( ( G.scene->basact ) &&
( ( G.scene->basact->flag & SELECT ) &&
( G.scene->basact->lay & G.vd->lay ) ) ) {
@@ -789,16 +790,14 @@ static PyObject *M_Object_GetSelected( PyObject * self )
base_iter = G.scene->base.first;
while( base_iter ) {
if( ( ( base_iter->flag & SELECT ) &&
( base_iter->lay & G.vd->lay ) ) &&
( base_iter->lay & G.vd->lay ) ) &&
( base_iter != G.scene->basact ) ) {
blen_object = Object_CreatePyObject( base_iter->object );
if( !blen_object ) {
Py_DECREF( list );
Py_RETURN_NONE;
if( blen_object ) {
PyList_Append( list, blen_object );
Py_DECREF( blen_object );
}
PyList_Append( list, blen_object );
Py_DECREF( blen_object );
}
base_iter = base_iter->next;
}

View File

@@ -875,11 +875,7 @@ static PyObject *Scene_getActiveObject(BPy_Scene *self)
ob = ((scene->basact) ? (scene->basact->object) : 0);
if (ob) {
PyObject *arg = Py_BuildValue("(s)", ob->id.name+2);
pyob = M_Object_Get(Py_None, arg);
Py_DECREF(arg);
pyob = Object_CreatePyObject( ob );
if (!pyob)
return EXPP_ReturnPyObjError(PyExc_MemoryError,
@@ -895,8 +891,9 @@ static PyObject *Scene_getActiveObject(BPy_Scene *self)
static PyObject *Scene_getCurrentCamera( BPy_Scene * self )
{
Object *cam_obj;
PyObject *pyob;
Scene *scene = self->scene;
if( !scene )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Blender Scene was deleted!" );
@@ -904,16 +901,11 @@ static PyObject *Scene_getCurrentCamera( BPy_Scene * self )
cam_obj = scene->camera;
if( cam_obj ) { /* if found, return a wrapper for it */
PyObject *camera = NULL;
PyObject *name = Py_BuildValue( "(s)", cam_obj->id.name + 2 );
if( !name )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Py_BuildValue() failed" );
camera = M_Object_Get( Py_None, name );
Py_DECREF ( name );
return camera;
pyob = Object_CreatePyObject( cam_obj );
if (!pyob)
return EXPP_ReturnPyObjError(PyExc_MemoryError,
"couldn't create new object wrapper!");
return pyob;
}
Py_INCREF( Py_None ); /* none found */