wasnt decref'ing items I got from PySequence_GetItem for PolyFill or ob.join() fixed and tested, memory dosent increse when used in a large loop.
This commit is contained in:
@@ -1571,34 +1571,37 @@ PyObject *M_Mathutils_PolyFill( PyObject * self, PyObject * args )
|
|||||||
for( i = 0; i < len_polylines; ++i ) {
|
for( i = 0; i < len_polylines; ++i ) {
|
||||||
polyLine= PySequence_GetItem( polyLineList, i );
|
polyLine= PySequence_GetItem( polyLineList, i );
|
||||||
|
|
||||||
if (EXPP_check_sequence_consistency( polyLine, &vector_Type ) != 1)
|
|
||||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
||||||
"expected a list of poly lines" );
|
|
||||||
|
|
||||||
len_polypoints= PySequence_Size( polyLine );
|
len_polypoints= PySequence_Size( polyLine );
|
||||||
|
if (len_polypoints>2) { /* dont bother adding edges as polylines */
|
||||||
dl= MEM_callocN(sizeof(DispList), "poly disp");
|
if (EXPP_check_sequence_consistency( polyLine, &vector_Type ) != 1)
|
||||||
BLI_addtail(&dispbase, dl);
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||||
dl->type= DL_INDEX3;
|
"expected a list of poly lines" );
|
||||||
dl->nr= len_polypoints;
|
|
||||||
dl->type= DL_POLY;
|
|
||||||
dl->parts= 1; /* no faces, 1 edge loop */
|
|
||||||
dl->col= 0; /* no material */
|
|
||||||
dl->verts= fp= MEM_callocN( sizeof(float)*3*len_polypoints, "dl verts");
|
|
||||||
dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index");
|
|
||||||
|
|
||||||
for( index = 0; index<len_polypoints; ++index, fp+=3) {
|
|
||||||
polyVec= PySequence_GetItem( polyLine, index );
|
|
||||||
|
|
||||||
fp[0] = ((VectorObject *)polyVec)->vec[0];
|
dl= MEM_callocN(sizeof(DispList), "poly disp");
|
||||||
fp[1] = ((VectorObject *)polyVec)->vec[1];
|
BLI_addtail(&dispbase, dl);
|
||||||
if( ((VectorObject *)polyVec)->size > 2 )
|
dl->type= DL_INDEX3;
|
||||||
fp[2] = ((VectorObject *)polyVec)->vec[2];
|
dl->nr= len_polypoints;
|
||||||
else
|
dl->type= DL_POLY;
|
||||||
fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */
|
dl->parts= 1; /* no faces, 1 edge loop */
|
||||||
|
dl->col= 0; /* no material */
|
||||||
|
dl->verts= fp= MEM_callocN( sizeof(float)*3*len_polypoints, "dl verts");
|
||||||
|
dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index");
|
||||||
|
|
||||||
totpoints++;
|
for( index = 0; index<len_polypoints; ++index, fp+=3) {
|
||||||
|
polyVec= PySequence_GetItem( polyLine, index );
|
||||||
|
|
||||||
|
fp[0] = ((VectorObject *)polyVec)->vec[0];
|
||||||
|
fp[1] = ((VectorObject *)polyVec)->vec[1];
|
||||||
|
if( ((VectorObject *)polyVec)->size > 2 )
|
||||||
|
fp[2] = ((VectorObject *)polyVec)->vec[2];
|
||||||
|
else
|
||||||
|
fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */
|
||||||
|
|
||||||
|
totpoints++;
|
||||||
|
Py_DECREF(polyVec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Py_DECREF(polyLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totpoints) {
|
if (totpoints) {
|
||||||
|
|||||||
@@ -2077,6 +2077,7 @@ static PyObject *Object_join( BPy_Object * self, PyObject * args )
|
|||||||
} else {
|
} else {
|
||||||
/* List item is an object, is it the same type? */
|
/* List item is an object, is it the same type? */
|
||||||
child = ( Object * ) Object_FromPyObject( py_child );
|
child = ( Object * ) Object_FromPyObject( py_child );
|
||||||
|
Py_DECREF (py_child);
|
||||||
if (parent->type == child->type) {
|
if (parent->type == child->type) {
|
||||||
|
|
||||||
if (object_in_scene( child, G.scene )==NULL) {
|
if (object_in_scene( child, G.scene )==NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user