Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-05-25 20:43:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-05-25 20:43:25 +0400
commitf231bd0d5715ac67767f96f3a8d20ebf618f7b03 (patch)
tree34c05572641b2eafad9fa8e342724e0b05b6b3d8 /source/blender/python/api2_2x/NMesh.c
parenta21f8292d9aeff54153fc65560d56b3d4f33575a (diff)
Many long standing memory leaks fixed in the BPY api.
Data from Armature.c and logic.c still leaks. Mostly todo with PyList_Append adding a refcount and the bpython api not decrefing. Also added some features needed to fix a bug in mesh_clean.py (ob.pinShape and ob.activeShape)
Diffstat (limited to 'source/blender/python/api2_2x/NMesh.c')
-rw-r--r--source/blender/python/api2_2x/NMesh.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index ffc74289510..0eb90d348ce 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -1275,10 +1275,10 @@ static PyObject *NMesh_getSelectedFaces( PyObject * self, PyObject * args )
BPy_NMesh *nm = ( BPy_NMesh * ) self;
Mesh *me = nm->mesh;
int flag = 0;
-
+
MTFace *tf;
int i;
- PyObject *l = PyList_New( 0 );
+ PyObject *l = PyList_New( 0 ), *pyval;
if( me == NULL )
return NULL;
@@ -1292,15 +1292,16 @@ static PyObject *NMesh_getSelectedFaces( PyObject * self, PyObject * args )
if( flag ) {
for( i = 0; i < me->totface; i++ ) {
- if( tf[i].flag & TF_SELECT )
- PyList_Append( l, PyInt_FromLong( i ) );
+ if( tf[i].flag & TF_SELECT ) {
+ pyval = PyInt_FromLong( i );
+ PyList_Append( l, pyval );
+ Py_DECREF(pyval);
+ }
}
} else {
for( i = 0; i < me->totface; i++ ) {
if( tf[i].flag & TF_SELECT )
- PyList_Append( l,
- PyList_GetItem( nm->faces,
- i ) );
+ PyList_Append( l, PyList_GetItem( nm->faces, i ) );
}
}
return l;
@@ -2434,11 +2435,13 @@ static PyObject *M_NMesh_GetRaw( PyObject * self, PyObject * args )
static PyObject *M_NMesh_GetNames(PyObject *self)
{
- PyObject *names = PyList_New(0);
+ PyObject *names = PyList_New(0), *tmpstr;
Mesh *me = G.main->mesh.first;
while (me) {
- PyList_Append(names, PyString_FromString(me->id.name+2));
+ tmpstr = PyString_FromString(me->id.name+2);
+ PyList_Append(names, tmpstr);
+ Py_DECREF(tmpstr);
me = me->id.next;
}
@@ -4095,7 +4098,7 @@ static PyObject *NMesh_renameVertGroup( PyObject * self, PyObject * args )
static PyObject *NMesh_getVertGroupNames( PyObject * self )
{
bDeformGroup *defGroup;
- PyObject *list;
+ PyObject *list, *tmpstr;
if( !( ( BPy_NMesh * ) self )->object )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
@@ -4103,11 +4106,15 @@ static PyObject *NMesh_getVertGroupNames( PyObject * self )
list = PyList_New( 0 );
for( defGroup = ( ( ( BPy_NMesh * ) self )->object )->defbase.first;
- defGroup; defGroup = defGroup->next ) {
- if( PyList_Append
- ( list, PyString_FromString( defGroup->name ) ) < 0 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Couldn't add item to list" );
+ defGroup; defGroup = defGroup->next ) {
+
+ tmpstr = PyString_FromString( defGroup->name );
+ if( PyList_Append( list, tmpstr) < 0 ) {
+ Py_XDECREF(list);
+ Py_XDECREF(tmpstr);
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError, "Couldn't add item to list" );
+ }
+ Py_XDECREF(tmpstr);
}
return list;