[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10837] trunk/blender/source/blender/ python/api2_2x/NMesh.c: When converting from TF_SELECT to use the mfaces selection flag only I missed getSelectedFaces .

Campbell Barton cbarton at metavr.com
Fri Jun 1 04:33:23 CEST 2007


Revision: 10837
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10837
Author:   campbellbarton
Date:     2007-06-01 04:33:23 +0200 (Fri, 01 Jun 2007)

Log Message:
-----------
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)

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/NMesh.c

Modified: trunk/blender/source/blender/python/api2_2x/NMesh.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/NMesh.c	2007-06-01 02:21:11 UTC (rev 10836)
+++ trunk/blender/source/blender/python/api2_2x/NMesh.c	2007-06-01 02:33:23 UTC (rev 10837)
@@ -1278,23 +1278,33 @@
 	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 @@
 		}
 	} 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 ) );
 		}
 	}





More information about the Bf-blender-cvs mailing list