From f19b56a541c1c8923fc64adefd7e250c5b55b965 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Jun 2007 02:33:23 +0000 Subject: When converting from TF_SELECT to use the mfaces selection flag only I missed getSelectedFaces. This broke theeths UV-Exportscript. updated and added 2 missing decref's, as well as a check not to write a list of faces greater then the size of the NMesh (mesh and NMesh face lengths can differ) --- source/blender/python/api2_2x/NMesh.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index 5c86a344896..b0ab64a6249 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -1278,23 +1278,33 @@ static PyObject *NMesh_getSelectedFaces( PyObject * self, PyObject * args ) Mesh *me = nm->mesh; int flag = 0; - MTFace *tf; + MFace *mf; int i; PyObject *l = PyList_New( 0 ), *pyval; - if( me == NULL ) + /* dont allow returning more then the NMesh's number of faces */ + int totfaces = PySequence_Length(nm->faces); + + if( me == NULL ) { + Py_DECREF(l); return NULL; - - tf = me->mtface; - if( tf == 0 ) + } + mf = me->mface; + if( mf == NULL ) return l; - if( !PyArg_ParseTuple( args, "|i", &flag ) ) + if( !PyArg_ParseTuple( args, "|i", &flag ) ) { + Py_DECREF(l); return NULL; - + } + + /* make sure not to write more faces then we have */ + if (totfaces > me->totface) + totfaces= me->totface; + if( flag ) { for( i = 0; i < me->totface; i++ ) { - if( tf[i].flag & TF_SELECT ) { + if( mf[i].flag & ME_FACE_SEL ) { pyval = PyInt_FromLong( i ); PyList_Append( l, pyval ); Py_DECREF(pyval); @@ -1302,7 +1312,7 @@ static PyObject *NMesh_getSelectedFaces( PyObject * self, PyObject * args ) } } else { for( i = 0; i < me->totface; i++ ) { - if( tf[i].flag & TF_SELECT ) + if( mf[i].flag & ME_FACE_SEL ) PyList_Append( l, PyList_GetItem( nm->faces, i ) ); } } -- cgit v1.2.3