diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-06-01 06:33:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-06-01 06:33:23 +0400 |
commit | f19b56a541c1c8923fc64adefd7e250c5b55b965 (patch) | |
tree | 7ffa22ff1aa9360ada7f88c3a2623f5f1460a675 /source | |
parent | 1a9f0e692acc3d5b2b9111e781d5e4a018c811d5 (diff) |
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)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/api2_2x/NMesh.c | 28 |
1 files changed, 19 insertions, 9 deletions
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 ) ); } } |