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)
This commit is contained in:
2007-05-25 16:43:25 +00:00
parent a21f8292d9
commit f231bd0d57
25 changed files with 364 additions and 218 deletions

View File

@@ -877,6 +877,7 @@ int BPY_menu_do_python( short menutype, int event )
if( !setup_armature_weakrefs()){
printf("Oops - weakref dict\n");
MEM_freeN( buffer );
return 0;
}

View File

@@ -118,17 +118,18 @@ static PyMethodDef BPy_BonesDict_methods[] = {
//-----------------(internal)
static int BoneMapping_Init(PyObject *dictionary, ListBase *bones){
Bone *bone = NULL;
PyObject *py_bone = NULL;
PyObject *py_bone = NULL, *str;
for (bone = bones->first; bone; bone = bone->next){
py_bone = PyBone_FromBone(bone);
if (!py_bone)
return -1;
if(PyDict_SetItem(dictionary,
PyString_FromString(bone->name), py_bone) == -1){
str = PyString_FromString(bone->name);
if(PyDict_SetItem(dictionary, str, py_bone) == -1)
return -1;
}
Py_DECREF(str);
Py_DECREF(py_bone);
if (bone->childbase.first)
BoneMapping_Init(dictionary, &bone->childbase);
@@ -138,17 +139,18 @@ static int BoneMapping_Init(PyObject *dictionary, ListBase *bones){
//-----------------(internal)
static int EditBoneMapping_Init(PyObject *dictionary, ListBase *editbones){
EditBone *editbone = NULL;
PyObject *py_editbone = NULL;
PyObject *py_editbone = NULL, *str;
for (editbone = editbones->first; editbone; editbone = editbone->next){
py_editbone = PyEditBone_FromEditBone(editbone);
if (!py_editbone)
return -1;
if(PyDict_SetItem(dictionary,
PyString_FromString(editbone->name), py_editbone) == -1){
str = PyString_FromString(editbone->name);
if(PyDict_SetItem(dictionary, str, py_editbone) == -1)
return -1;
}
Py_DECREF(str);
Py_DECREF(py_editbone);
}
return 0;
@@ -215,7 +217,7 @@ static void BonesDict_dealloc(BPy_BonesDict * self)
Py_DECREF(self->bonesMap);
Py_DECREF(self->editbonesMap);
BLI_freelistN(&self->editbones);
BonesDict_Type.tp_free(self);
PyObject_DEL( self );
return;
}
//------------------------mp_length
@@ -422,10 +424,7 @@ PyTypeObject BonesDict_Type = {
//-----------------------PyBonesDict_FromPyArmature
static PyObject *PyBonesDict_FromPyArmature(BPy_Armature *py_armature)
{
BPy_BonesDict *py_BonesDict = NULL;
//create py object
py_BonesDict = (BPy_BonesDict *)BonesDict_Type.tp_alloc(&BonesDict_Type, 0);
BPy_BonesDict *py_BonesDict = (BPy_BonesDict *)PyObject_NEW( BPy_BonesDict, &BonesDict_Type );
if (!py_BonesDict)
goto RuntimeError;
@@ -1067,9 +1066,9 @@ static void Armature_dealloc(BPy_Armature * self)
{
if (self->weaklist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
Py_DECREF(self->Bones);
Armature_Type.tp_free(self);
return;
PyObject_DEL( self );
}
//------------------TYPE_OBECT DEFINITION--------------------------
PyTypeObject Armature_Type = {
@@ -1126,7 +1125,7 @@ PyTypeObject Armature_Type = {
//----------------Blender.Armature.Get()
/* This function will return a Py_Armature when a single string is passed
* or else it will return a {key:value} dictionary when mutliple strings are passed
* or it will return a {key:value} dictionary of all armatures when nothing is passed*/
* or it will return a {key:value} dictionary of all armatures when nothing is passed */
static PyObject *M_Armature_Get(PyObject * self, PyObject * args)
{
PyObject *seq = NULL, *item = NULL, *dict = NULL, *py_armature = NULL;
@@ -1291,8 +1290,12 @@ PyObject *Armature_RebuildBones(PyObject *pyarmature)
{
return Armature_update((BPy_Armature*)pyarmature);
}
//-----------------(internal)
//Converts a bArmature to a PyArmature
/*-----------------(internal)
* Converts a bArmature to a PyArmature
*
* WARNING!!! - MEMORY LEAK HERE, Run in a loop and loose your ram.
* cannot find out why but dosnt seam to be the weakref */
PyObject *Armature_CreatePyObject(struct bArmature *armature)
{
BPy_Armature *py_armature = NULL;
@@ -1300,15 +1303,16 @@ PyObject *Armature_CreatePyObject(struct bArmature *armature)
PyObject *armlist = NULL; /* list of armature weak refs */
char *list_name = ARM_WEAKREF_LIST_NAME;
//create armature type
py_armature = (BPy_Armature*)Armature_Type.tp_alloc(&Armature_Type, 0); /*new*/
/*create armature type*/
py_armature = PyObject_NEW( BPy_Armature, &Armature_Type );
if (!py_armature){
printf("Oops - can't create py armature\n");
goto RuntimeError;
}
py_armature->weaklist = NULL; //init the weaklist
py_armature->armature = armature;
py_armature->weaklist = NULL; //init the weaklist
//create armature.bones
py_armature->Bones = (BPy_BonesDict*)PyBonesDict_FromPyArmature(py_armature);

View File

@@ -88,9 +88,9 @@ static PyObject *EditBone_hasParent(BPy_EditBone *self)
{
if (self->editbone){
if (self->editbone->parent)
return EXPP_incr_ret(Py_True);
Py_RETURN_TRUE;
else
return EXPP_incr_ret(Py_False);
Py_RETURN_FALSE;
}else{
goto AttributeError;
}
@@ -105,7 +105,7 @@ static PyObject *EditBone_clearParent(BPy_EditBone *self)
if (self->editbone){
if (self->editbone->parent)
self->editbone->parent = NULL;
return EXPP_incr_ret(Py_None);
Py_RETURN_NONE;
}else{
goto AttributeError;
}
@@ -406,9 +406,10 @@ static PyObject *EditBone_getOptions(BPy_EditBone *self, void *closure)
goto RuntimeError;
}
return EXPP_incr_ret(list);
return list;
RuntimeError:
Py_XDECREF( list );
return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
sEditBoneError, ".options: ", "Internal failure!");
}
@@ -515,9 +516,9 @@ static PyObject *EditBone_getParent(BPy_EditBone *self, void *closure)
if (self->editbone->parent)
return PyEditBone_FromEditBone(self->editbone->parent);
else
return EXPP_incr_ret(Py_None);
Py_RETURN_NONE;
}else{
return EXPP_incr_ret(Py_None); //not in the list yet can't have a parent
Py_RETURN_NONE; //not in the list yet can't have a parent
}
}
//------------------------EditBone.parent (set)
@@ -878,45 +879,47 @@ static int PyBone_ChildrenAsList(PyObject *list, ListBase *bones){
py_bone = PyBone_FromBone(bone);
if (py_bone == NULL)
return 0;
if(PyList_Append(list, py_bone) == -1){
goto RuntimeError;
return 0;
}
Py_DECREF(py_bone);
if (bone->childbase.first)
PyBone_ChildrenAsList(list, &bone->childbase);
if (!PyBone_ChildrenAsList(list, &bone->childbase))
return 0;
}
return 1;
RuntimeError:
return EXPP_intError(PyExc_RuntimeError, "%s%s",
sBoneError, "Internal error trying to wrap blender bones!");
}
//-------------------------Bone.hasParent()
static PyObject *Bone_hasParent(BPy_Bone *self)
{
if (self->bone->parent)
return EXPP_incr_ret(Py_True);
Py_RETURN_TRUE;
else
return EXPP_incr_ret(Py_False);
Py_RETURN_FALSE;
}
//-------------------------Bone.hasChildren()
static PyObject *Bone_hasChildren(BPy_Bone *self)
{
if (self->bone->childbase.first)
return EXPP_incr_ret(Py_True);
Py_RETURN_TRUE;
else
return EXPP_incr_ret(Py_False);
Py_RETURN_FALSE;
}
//-------------------------Bone.getAllChildren()
static PyObject *Bone_getAllChildren(BPy_Bone *self)
{
PyObject *list = PyList_New(0);
if (self->bone->childbase.first)
if (!PyBone_ChildrenAsList(list, &self->bone->childbase))
return NULL;
return EXPP_incr_ret(list);
if (!self->bone->childbase.first) {
/* do nothing */
} else if (!PyBone_ChildrenAsList(list, &self->bone->childbase)) {
Py_XDECREF(list);
EXPP_objError(PyExc_RuntimeError, "%s%s",
sBoneError, "Internal error trying to wrap blender bones!");
}
return list;
}
//------------------ATTRIBUTE IMPLEMENTATIONS-----------------------------
//------------------------Bone.name (get)
static PyObject *Bone_getName(BPy_Bone *self, void *closure)
@@ -1044,9 +1047,10 @@ static PyObject *Bone_getOptions(BPy_Bone *self, void *closure)
EXPP_GetModuleConstant("Blender.Armature", "TIP_SELECTED")) == -1)
goto RuntimeError;
return EXPP_incr_ret(list);
return list;
RuntimeError:
Py_XDECREF(list);
return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
sBoneError, "getOptions(): ", "Internal failure!");
}
@@ -1062,7 +1066,7 @@ static PyObject *Bone_getParent(BPy_Bone *self, void *closure)
if (self->bone->parent)
return PyBone_FromBone(self->bone->parent);
else
return EXPP_incr_ret(Py_None);
Py_RETURN_NONE;
}
//------------------------Bone.parent (set)
static int Bone_setParent(BPy_Bone *self, PyObject *value, void *closure)
@@ -1081,15 +1085,17 @@ static PyObject *Bone_getChildren(BPy_Bone *self, void *closure)
for (bone = self->bone->childbase.first; bone; bone = bone->next){
py_bone = PyBone_FromBone(bone);
if (py_bone == NULL)
return 0;
if(PyList_Append(list, py_bone) == -1){
goto RuntimeError;
}
if (PyList_Append(list, py_bone) == -1)
goto RuntimeError;
Py_DECREF(py_bone);
}
}
return EXPP_incr_ret(list);
return list;
RuntimeError:
Py_XDECREF(list);
Py_XDECREF(py_bone);
return EXPP_objError(PyExc_RuntimeError, "%s%s",
sBoneError, "Internal error trying to wrap blender bones!");
}
@@ -1309,19 +1315,11 @@ RuntimeError:
//Converts a struct Bone to a BPy_Bone
PyObject *PyBone_FromBone(struct Bone *bone)
{
BPy_Bone *py_Bone = NULL;
py_Bone = (BPy_Bone*)Bone_Type.tp_alloc(&Bone_Type, 0); //*new*
if (py_Bone == NULL)
goto RuntimeError;
BPy_Bone *py_Bone = ( BPy_Bone * ) PyObject_NEW( BPy_Bone, &Bone_Type );
py_Bone->bone = bone;
return (PyObject *) py_Bone;
RuntimeError:
return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
sBoneError, "PyBone_FromBone: ", "Internal Error Ocurred");
}
//-----------------(internal)
//Converts a PyBone to a bBone

View File

@@ -947,8 +947,7 @@ PyObject *CurNurb_pointAtIndex( Nurb * nurb, int index )
for( i = 0; i < 4; i++ ) {
PyList_SetItem( pyo, i,
PyFloat_FromDouble( nurb->bp[index].
vec[i] ) );
PyFloat_FromDouble( nurb->bp[index].vec[i] ) );
}
/* add Tilt only if curve is 3D */

View File

@@ -1396,7 +1396,7 @@ static PyObject *M_Curve_Get( PyObject * self, PyObject * args )
&Curve_Type );
found_cur->curve = curv_iter;
PyList_Append( curvlist, ( PyObject * ) found_cur );
Py_DECREF(found_cur);
curv_iter = curv_iter->id.next;
}

View File

@@ -787,9 +787,11 @@ static void exec_but_callback(void *pyobj, void *data)
}
case BUT:
pyvalue = Py_None;
Py_INCREF(pyvalue);
break;
default:
pyvalue = Py_None;
Py_INCREF(pyvalue);
printf("Error, no button type matched.");
}
@@ -802,6 +804,7 @@ static void exec_but_callback(void *pyobj, void *data)
result = PyObject_CallObject( callback, arg );
if (!result) {
Py_DECREF(pyvalue);
PyErr_Print( );
error( "Python script error: check console" );
}

View File

@@ -1494,7 +1494,7 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
Effect *eff;
PartEff *paf;
Particle *pa=0;
PyObject *list, *strand_list;
PyObject *list, *strand_list, *pyvec;
float p_time, c_time, vec[3], vec1[3], cfra, m_time, s_time;
int a;
short disp=100 ;
@@ -1545,12 +1545,17 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
for(c_time= pa->time; c_time<m_time; c_time+=paf->staticstep) {
where_is_particle(paf, pa, c_time, vec);
MTC_Mat4MulVecfl(ob->obmat, vec); /* make worldspace like the others */
if( PyList_Append( strand_list, newVectorObject(vec, 3, Py_NEW)) < 0 ) {
pyvec = newVectorObject(vec, 3, Py_NEW);
if( PyList_Append( strand_list, pyvec) < 0 ) {
Py_DECREF( list );
Py_DECREF( strand_list );
Py_XDECREF( pyvec );
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Couldn't append item to PyList" );
}
Py_DECREF( pyvec );
}
if( PyList_Append( list, strand_list) < 0 ) {
@@ -1589,12 +1594,14 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
}
} else { /* not a vector */
where_is_particle(paf, pa, c_time, vec);
if( PyList_Append( list,
newVectorObject(vec, 3, Py_NEW)) < 0 ) {
pyvec = newVectorObject(vec, 3, Py_NEW);
if( PyList_Append( list, pyvec) < 0 ) {
Py_DECREF( list );
Py_XDECREF( pyvec );
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Couldn't append item to PyList" );
}
Py_DECREF( pyvec );
}
}
}

View File

@@ -374,7 +374,7 @@ static PyObject *Font_repr( BPy_Font * self )
return PyString_FromFormat( "[Font \"%s\"]",
self->font->id.name+2 );
else
return PyString_FromString( "NULL" );
return PyString_FromString( "[Font - no data]" );
}
/*--------------- compare------------------------------------------*/

View File

@@ -197,7 +197,7 @@ static PyGetSetDef BPy_Ipo_getseters[] = {
(getter)Ipo_getBlocktype, (setter)NULL,
"Ipo block type",
NULL},
{"rcft",
{"rctf",
(getter)Ipo_getRctf, (setter)Ipo_setRctf,
"Ipo type",
NULL},
@@ -830,11 +830,11 @@ static int Ipo_setBlocktype( BPy_Ipo * self, PyObject * args )
static PyObject *Ipo_getRctf( BPy_Ipo * self )
{
PyObject *l = PyList_New( 0 );
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.xmin ) );
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.xmax ) );
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.ymin ) );
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.ymax ) );
PyObject *l = PyList_New( 4 );
PyList_SET_ITEM( l, 0, PyFloat_FromDouble( self->ipo->cur.xmin ) );
PyList_SET_ITEM( l, 1, PyFloat_FromDouble( self->ipo->cur.xmax ) );
PyList_SET_ITEM( l, 2, PyFloat_FromDouble( self->ipo->cur.ymin ) );
PyList_SET_ITEM( l, 3, PyFloat_FromDouble( self->ipo->cur.ymax ) );
return l;
}
@@ -1018,12 +1018,14 @@ typeError:
static PyObject *Ipo_getCurves( BPy_Ipo * self )
{
PyObject *attr = PyList_New( 0 );
PyObject *attr = PyList_New( 0 ), *pyipo;
IpoCurve *icu;
for( icu = self->ipo->curve.first; icu; icu = icu->next )
PyList_Append( attr, IpoCurve_CreatePyObject( icu ) );
for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
pyipo = IpoCurve_CreatePyObject( icu );
PyList_Append( attr, pyipo );
Py_DECREF(pyipo);
}
return attr;
}
@@ -1110,14 +1112,16 @@ static PyObject *Ipo_getCurveNames( BPy_Ipo * self )
/* find the ipo in the keylist */
for( key = G.main->key.first; key; key = key->id.next ) {
if( key->ipo == self->ipo ) {
PyObject *tmpstr;
KeyBlock *block = key->block.first;
attr = PyList_New( 0 );
/* add each name to the list */
for( block = key->block.first; block; block = block->next )
PyList_Append( attr,
PyString_FromString( block->name ) );
for( block = key->block.first; block; block = block->next ) {
tmpstr = PyString_FromString( block->name );
PyList_Append( attr, tmpstr);
Py_DECREF(tmpstr);
}
return attr;
}
}
@@ -1674,7 +1678,7 @@ static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args )
struct BezTriple *ptrbt;
int num = 0, pos, i, j;
IpoCurve *icu;
PyObject *l = PyList_New( 0 );
PyObject *l = PyList_New( 0 ), *pyfloat;
if( !PyArg_ParseTuple( args, "ii", &num, &pos ) )
return ( EXPP_ReturnPyObjError
@@ -1698,11 +1702,13 @@ static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"No bez triple" );
for( i = 0; i < 3; i++ )
for( j = 0; j < 3; j++ )
PyList_Append( l,
PyFloat_FromDouble( ptrbt->
vec[i][j] ) );
for( i = 0; i < 3; i++ ) {
for( j = 0; j < 3; j++ ) {
pyfloat = PyFloat_FromDouble( ptrbt->vec[i][j] );
PyList_Append( l, pyfloat );
Py_DECREF(pyfloat);
}
}
return l;
}
@@ -1823,8 +1829,7 @@ static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args )
if( icu )
return PyFloat_FromDouble( icu->curval );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
/*

View File

@@ -64,6 +64,7 @@
static int Key_compare( BPy_Key * a, BPy_Key * b );
static PyObject *Key_repr( BPy_Key * self );
static void Key_dealloc( BPy_Key * self );
static PyObject *Key_getBlocks( BPy_Key * self );
static PyObject *Key_getType( BPy_Key * self );
@@ -106,6 +107,10 @@ static int KeyBlock_setVgroup( BPy_KeyBlock *, PyObject * args );
static int KeyBlock_setSlidermin( BPy_KeyBlock *, PyObject * args );
static int KeyBlock_setSlidermax( BPy_KeyBlock *, PyObject * args );
static void KeyBlock_dealloc( BPy_KeyBlock * self );
static int KeyBlock_compare( BPy_KeyBlock * a, BPy_KeyBlock * b );
static PyObject *KeyBlock_repr( BPy_KeyBlock * self );
static struct PyMethodDef KeyBlock_methods[] = {
{ "getData", (PyCFunction) KeyBlock_getData, METH_NOARGS,
"Get keyblock data" },
@@ -136,7 +141,7 @@ PyTypeObject Key_Type = {
sizeof( BPy_Key ), /*tp_basicsize */
0, /*tp_itemsize */
/* methods */
NULL, /*tp_dealloc */
( destructor ) Key_dealloc,/* destructor tp_dealloc; */
( printfunc ) 0, /*tp_print */
( getattrfunc ) 0, /*tp_getattr */
( setattrfunc ) 0, /*tp_setattr */
@@ -213,12 +218,12 @@ PyTypeObject KeyBlock_Type = {
sizeof( BPy_KeyBlock ), /*tp_basicsize */
0, /*tp_itemsize */
/* methods */
NULL, /*tp_dealloc */
NULL, /*tp_print */
NULL, /*tp_getattr */
NULL, /*tp_setattr */
NULL, /*tp_compare*/
NULL, /* tp_repr */
( destructor ) KeyBlock_dealloc,/* destructor tp_dealloc; */
( printfunc ) 0, /*tp_print */
( getattrfunc ) 0, /*tp_getattr */
( setattrfunc ) 0, /*tp_setattr */
( cmpfunc) KeyBlock_compare, /*tp_compare*/
( reprfunc ) KeyBlock_repr, /* tp_repr */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
@@ -303,6 +308,10 @@ PyObject *Key_CreatePyObject( Key * k )
return ( PyObject * ) key;
}
static void Key_dealloc( BPy_Key * self )
{
PyObject_DEL( self );
}
static int Key_compare( BPy_Key * a, BPy_Key * b )
{
@@ -378,14 +387,12 @@ static PyObject *Key_getBlocks( BPy_Key * self )
{
Key *key = self->key;
KeyBlock *kb;
PyObject *keyblock_object;
PyObject *l = PyList_New( 0 );
for (kb = key->block.first; kb; kb = kb->next) {
keyblock_object = KeyBlock_CreatePyObject( kb, key );
PyList_Append( l, keyblock_object );
}
int i=0;
PyObject *l = PyList_New( BLI_countlist( &(key->block)) );
for (kb = key->block.first; kb; kb = kb->next, i++)
PyList_SET_ITEM( l, i, KeyBlock_CreatePyObject( kb, key ) );
return l;
}
@@ -398,17 +405,11 @@ static PyObject *Key_getValue( BPy_Key * self )
/* ------------ Key Block Functions -------------- */
static PyObject *new_KeyBlock( KeyBlock * oldkeyBlock, Key *parentKey)
static PyObject *new_KeyBlock( KeyBlock * keyblock, Key *key)
{
BPy_KeyBlock *kb = PyObject_NEW( BPy_KeyBlock, &KeyBlock_Type );
kb->key = parentKey;
if( !oldkeyBlock ) {
kb->keyblock = 0;
} else {
kb->keyblock = oldkeyBlock;
}
kb->key = key;
kb->keyblock = keyblock; /* keyblock maye be NULL, thats ok */
return ( PyObject * ) kb;
}
@@ -478,6 +479,22 @@ static int KeyBlock_setSlidermax( BPy_KeyBlock * self, PyObject * args ){
10.0f );
}
static void KeyBlock_dealloc( BPy_KeyBlock * self )
{
PyObject_DEL( self );
}
static int KeyBlock_compare( BPy_KeyBlock * a, BPy_KeyBlock * b )
{
return ( a->keyblock == b->keyblock ) ? 0 : -1;
}
static PyObject *KeyBlock_repr( BPy_KeyBlock * self )
{
return PyString_FromFormat( "[KeyBlock \"%s\"]", self->keyblock->name );
}
static Curve *find_curve( Key *key )
{
Curve *cu;

View File

@@ -166,11 +166,11 @@ static PyObject *M_Lattice_New( PyObject * self, PyObject * args )
"expected string and int arguments (or nothing)" );
bl_Lattice = add_lattice( "Lattice" );
bl_Lattice->id.us = 0;
if( bl_Lattice )
if( bl_Lattice ) {
bl_Lattice->id.us = 0;
py_Lattice = Lattice_CreatePyObject( bl_Lattice );
else
} else
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Lattice Object in Blender" );
if( !py_Lattice )

View File

@@ -4972,15 +4972,15 @@ static PyObject *MFaceSeq_extend( BPy_MEdgeSeq * self, PyObject *args,
tmpface->flag = ME_FACE_SEL;
if( return_list )
PyList_Append( return_list,
PyInt_FromLong( mesh->totface ) );
if( return_list ) {
tmp = PyInt_FromLong( mesh->totface );
PyList_Append( return_list, tmp );
Py_DECREF(tmp);
}
mesh->totface++;
++tmpface;
--good_faces;
} else if( return_list ) {
Py_INCREF( Py_None );
PyList_Append( return_list, Py_None );
--good_faces;
}
@@ -5385,9 +5385,44 @@ static PyObject *Mesh_vertexShade( BPy_Mesh * self )
* force display list update
*/
static PyObject *Mesh_Update( BPy_Mesh * self )
static PyObject *Mesh_Update( BPy_Mesh * self, PyObject *args, PyObject *kwd )
{
mesh_update( self->mesh );
char *blockname= NULL;
static char *kwlist[] = {"key", NULL};
if( !PyArg_ParseTupleAndKeywords(args, kwd, "|s", kwlist, &blockname) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"Expected nothing or the name of a shapeKey");
if (blockname) {
Mesh *me = self->mesh;
MVert *mv = me->mvert;
Key *key= me->key;
KeyBlock *kb;
float (*co)[3];
int i;
if (!key)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Cannot update the key for this mesh, it has no shape keys");
for (kb = key->block.first; kb; kb=kb->next)
if (strcmp(blockname, kb->name))
break;
if (!kb)
return EXPP_ReturnPyObjError( PyExc_ValueError,
"This requested key to update does not exist");
printf("KEYBLOCKNAME %s\n", kb->name);
for(i=0, co= kb->data; i<me->totvert; i++, mv++, co++)
VECCOPY(*co, mv->co);
} else {
/* Normal operation */
mesh_update( self->mesh );
}
Py_RETURN_NONE;
}
@@ -5893,7 +5928,6 @@ static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * args )
{
char *groupStr;
struct Object *object;
PyObject *tempStr;
if( !PyArg_ParseTuple( args, "s", &groupStr ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -5905,10 +5939,7 @@ static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * args )
object = ( ( BPy_Mesh * ) self )->object;
/*get clamped name*/
tempStr = PyString_FromStringAndSize( groupStr, 32 );
groupStr = PyString_AsString( tempStr );
/* add_defgroup_name clamps the name to 32, make sure that dosnt change */
add_defgroup_name( object, groupStr );
EXPP_allqueue( REDRAWBUTSALL, 1 );
@@ -6502,7 +6533,7 @@ static PyObject *Mesh_getLayerNames_internal( BPy_Mesh * self, int type )
{
CustomData *data;
CustomDataLayer *layer;
PyObject *list = PyList_New( 0 );
PyObject *str, *list = PyList_New( 0 );
Mesh *mesh = self->mesh;
int i;
data = &mesh->fdata;
@@ -6511,7 +6542,9 @@ static PyObject *Mesh_getLayerNames_internal( BPy_Mesh * self, int type )
for(i=0; i<data->totlayer; i++) {
layer = &data->layers[i];
if(layer->type == type) {
PyList_Append( list, PyString_FromString(layer->name) );
str = PyString_FromString(layer->name);
PyList_Append( list, str );
Py_DECREF(str);
}
}
return list;
@@ -6990,7 +7023,7 @@ static struct PyMethodDef BPy_Mesh_methods[] = {
"find indices of an multiple edges in the mesh"},
{"getFromObject", (PyCFunction)Mesh_getFromObject, METH_VARARGS,
"Get a mesh by name"},
{"update", (PyCFunction)Mesh_Update, METH_NOARGS,
{"update", (PyCFunction)Mesh_Update, METH_VARARGS | METH_KEYWORDS,
"Update display lists after changes to mesh"},
{"transform", (PyCFunction)Mesh_transform, METH_VARARGS | METH_KEYWORDS,
"Applies a transformation matrix to mesh's vertices"},

View File

@@ -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;

View File

@@ -44,6 +44,7 @@ struct rctf;
#include "DNA_view3d_types.h"
#include "DNA_object_force.h"
#include "DNA_userdef_types.h"
#include "DNA_key_types.h" /* for pinShape and activeShape */
#include "BKE_action.h"
#include "BKE_anim.h" /* used for dupli-objects */
@@ -68,6 +69,7 @@ struct rctf;
#include "BKE_modifier.h"
#include "BKE_idprop.h"
#include "BKE_object.h"
#include "BKE_key.h" /* for setting the activeShape */
#include "BSE_editipo.h"
#include "BSE_edit.h"
@@ -174,6 +176,7 @@ enum obj_consts {
EXPP_OBJ_ATTR_PARENT_TYPE,
EXPP_OBJ_ATTR_PASSINDEX,
EXPP_OBJ_ATTR_ACT_MATERIAL,
EXPP_OBJ_ATTR_ACT_SHAPE,
EXPP_OBJ_ATTR_PI_SURFACEDAMP, /* these need to stay together */
EXPP_OBJ_ATTR_PI_RANDOMDAMP, /* and in order */
@@ -331,7 +334,6 @@ struct PyMethodDef M_Object_methods[] = {
static int setupSB(Object* ob); /*Make sure Softbody Pointer is initialized */
static int setupPI(Object* ob);
static PyObject *Object_GetProperties(BPy_Object * self);
static PyObject *Object_buildParts( BPy_Object * self );
static PyObject *Object_clearIpo( BPy_Object * self );
static PyObject *Object_clrParent( BPy_Object * self, PyObject * args );
@@ -756,8 +758,6 @@ works only if self and the object specified are of the same type."},
"([s1<,s2,s3...>]) - Delete specified scriptlinks from this object."},
{"insertShapeKey", ( PyCFunction ) Object_insertShapeKey, METH_NOARGS,
"() - Insert a Shape Key in the current object"},
{"getProperties", ( PyCFunction ) Object_GetProperties, METH_NOARGS,
"() return a reference to the ID properties associated with this object."},
{"__copy__", ( PyCFunction ) Object_copy, METH_NOARGS,
"() - Return a copy of this object."},
{"copy", ( PyCFunction ) Object_copy, METH_NOARGS,
@@ -1021,12 +1021,6 @@ static PyObject *M_Object_Duplicate( PyObject * self_unused,
/* Python BPy_Object methods: */
/*****************************************************************************/
static PyObject *Object_GetProperties(BPy_Object * self)
{
return BPy_Wrap_IDProperty( (ID*)self->object, IDP_GetProperties((ID*)self->object, 1), NULL );
}
static PyObject *Object_buildParts( BPy_Object * self )
{
build_particle_system( self->object );
@@ -2733,14 +2727,16 @@ static PyObject *Object_shareFrom( BPy_Object * self, PyObject * args )
static PyObject *Object_getAllProperties( BPy_Object * self )
{
PyObject *prop_list;
PyObject *prop_list, *pyval;
bProperty *prop = NULL;
prop_list = PyList_New( 0 );
prop = self->object->prop.first;
while( prop ) {
PyList_Append( prop_list, Property_CreatePyObject( prop ) );
pyval = Property_CreatePyObject( prop );
PyList_Append( prop_list, pyval );
Py_DECREF(pyval);
prop = prop->next;
}
return prop_list;
@@ -3019,7 +3015,7 @@ static int Object_setDupliGroup( BPy_Object * self, PyObject * value )
static PyObject *Object_getEffects( BPy_Object * self )
{
PyObject *effect_list;
PyObject *effect_list, *pyval;
Effect *eff;
effect_list = PyList_New( 0 );
@@ -3030,7 +3026,9 @@ static PyObject *Object_getEffects( BPy_Object * self )
eff = self->object->effect.first;
while( eff ) {
PyList_Append( effect_list, EffectCreatePyObject( eff, self->object ) );
pyval = EffectCreatePyObject( eff, self->object );
PyList_Append( effect_list, pyval );
Py_DECREF(pyval);
eff = eff->next;
}
return effect_list;
@@ -3571,6 +3569,9 @@ static PyObject *getIntAttr( BPy_Object *self, void *type )
case EXPP_OBJ_ATTR_ACT_MATERIAL:
param = object->actcol;
break;
case EXPP_OBJ_ATTR_ACT_SHAPE:
param = object->shapenr;
break;
default:
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"undefined type in getIntAttr" );
@@ -3632,6 +3633,20 @@ static int setIntAttrClamp( BPy_Object *self, PyObject *value, void *type )
size = 'b'; /* in case max is later made > 128 */
param = (void *)&object->actcol;
break;
case EXPP_OBJ_ATTR_ACT_SHAPE:
{
Key *key= ob_get_key(object);
KeyBlock *kb;
min = 1;
max = 0;
if (key) {
max= 1;
for (kb = key->block.first; kb; kb=kb->next, max++);
}
size = 'h'; /* in case max is later made > 128 */
param = (void *)&object->shapenr;
break;
}
default:
return EXPP_ReturnIntError( PyExc_RuntimeError,
"undefined type in setIntAttrClamp");
@@ -4144,6 +4159,26 @@ static int setFloat3Attr( BPy_Object *self, PyObject *value, void *type )
/* BPy_Object methods and attribute handlers */
/*****************************************************************************/
static PyObject *Object_getShapeFlag( BPy_Object *self, void *type )
{
if (self->object->shapeflag & (int)type)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Object_setShapeFlag( BPy_Object *self, PyObject *value,
void *type )
{
if (PyObject_IsTrue(value) )
self->object->shapeflag |= (int)type;
else
self->object->shapeflag &= ~(int)type;
self->object->recalc |= OB_RECALC_OB;
return 0;
}
static PyObject *Object_getRestricted( BPy_Object *self, void *type )
{
if (self->object->restrictflag & (int)type)
@@ -5013,8 +5048,16 @@ static PyGetSetDef BPy_Object_getseters[] = {
"Toggle object restrictions",
(void *)OB_RESTRICT_RENDER},
{"properties", (getter)Object_GetProperties, (setter)NULL,
"Get the ID properties associated with this object"},
{"pinShape",
(getter)Object_getShapeFlag, (setter)Object_setShapeFlag,
"Set the state for pinning this object",
(void *)OB_SHAPE_LOCK},
{"activeShape",
(getter)getIntAttr, (setter)setIntAttrClamp,
"set the index for the active shape key",
(void *)EXPP_OBJ_ATTR_ACT_SHAPE},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};

View File

@@ -452,6 +452,7 @@ static PyObject *Text_asLines( BPy_Text * self )
while( line ) {
ob = Py_BuildValue( "s", line->line );
PyList_Append( list, ob );
Py_DECREF(ob);
line = line->next;
}

View File

@@ -544,7 +544,7 @@ PyObject *M_Text3d_Get( PyObject * self, PyObject * args )
&Text3d_Type );
found_text3d->curve = curv_iter;
PyList_Append( curvlist, ( PyObject * ) found_text3d );
Py_DECREF(found_text3d);
curv_iter = curv_iter->id.next;
}
return ( curvlist );

View File

@@ -121,7 +121,7 @@ void types_InitAll( void )
Text_Type.ob_type = &PyType_Type;
Text3d_Type.ob_type = &PyType_Type;
Texture_Type.ob_type = &PyType_Type;
TimeLine_Type.ob_type = &PyType_Type;
//TimeLine_Type.ob_type = &PyType_Type;
World_Type.ob_type = &PyType_Type;
buffer_Type.ob_type = &PyType_Type;
constant_Type.ob_type = &PyType_Type;

View File

@@ -439,7 +439,8 @@ static PyObject *M_World_Get( PyObject * self, PyObject * args )
&World_Type );
found_world->world = world_iter;
PyList_Append( worldlist, ( PyObject * ) found_world );
Py_DECREF(found_world);
world_iter = world_iter->id.next;
}
return ( worldlist );
@@ -673,13 +674,13 @@ static PyObject *World_oldsetMistype( BPy_World * self, PyObject * args )
static PyObject *World_getHor( BPy_World * self )
{
PyObject *attr = PyList_New( 0 );
PyObject *attr = PyList_New( 3 );
if( !attr )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create list" ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->horr ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->horg ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->horb ) );
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->horr ) );
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->horg ) );
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->horb ) );
return attr;
}
@@ -705,13 +706,13 @@ static PyObject *World_oldsetHor( BPy_World * self, PyObject * args )
static PyObject *World_getZen( BPy_World * self )
{
PyObject *attr = PyList_New( 0 );
PyObject *attr = PyList_New( 3 );
if( !attr )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create list" ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->zenr ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->zeng ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->zenb ) );
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->zenr ) );
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->zeng ) );
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->zenb ) );
return attr;
}
@@ -738,13 +739,13 @@ static PyObject *World_oldsetZen( BPy_World * self, PyObject * args )
static PyObject *World_getAmb( BPy_World * self )
{
PyObject *attr = PyList_New( 0 );
PyObject *attr = PyList_New( 3 );
if( !attr )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create list" ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->ambr ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->ambg ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->ambb ) );
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->ambr ) );
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->ambg ) );
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->ambb ) );
return attr;
}
@@ -770,17 +771,17 @@ static PyObject *World_oldsetAmb( BPy_World * self, PyObject * args )
static PyObject *World_getStar( BPy_World * self )
{
PyObject *attr = PyList_New( 0 );
PyObject *attr = PyList_New( 7 );
if( !attr )
return ( EXPP_ReturnPyObjError
( PyExc_RuntimeError, "couldn't create list" ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->starr ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->starg ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->starb ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->starsize ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->starmindist ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->stardist ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->starcolnoise ) );
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->starr ) );
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->starg ) );
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->starb ) );
PyList_SET_ITEM( attr, 3, PyFloat_FromDouble( self->world->starsize ) );
PyList_SET_ITEM( attr, 4, PyFloat_FromDouble( self->world->starmindist ) );
PyList_SET_ITEM( attr, 5, PyFloat_FromDouble( self->world->stardist ) );
PyList_SET_ITEM( attr, 6, PyFloat_FromDouble( self->world->starcolnoise ) );
return attr;
}
@@ -815,18 +816,17 @@ static PyObject *World_oldsetStar( BPy_World * self, PyObject * args )
static PyObject *World_getMist( BPy_World * self )
{
PyObject *attr = PyList_New( 0 );
PyObject *attr = PyList_New( 4 );
if( !attr )
return ( EXPP_ReturnPyObjError
( PyExc_RuntimeError, "couldn't create list" ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->misi ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->miststa ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->mistdist ) );
PyList_Append( attr, PyFloat_FromDouble( self->world->misthi ) );
PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->misi ) );
PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->miststa ) );
PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->mistdist ) );
PyList_SET_ITEM( attr, 3, PyFloat_FromDouble( self->world->misthi ) );
return attr;
}
static int World_setMist( BPy_World * self, PyObject * value )
{
if( !PyList_Check( value ) )

View File

@@ -144,11 +144,13 @@ static PyObject *constant_getAttro(BPy_constant * self, PyObject *value)
static PyObject *constant_repr(BPy_constant * self)
{
char str[4096];
PyObject *key, *value;
PyObject *key, *value, *tempstr;
int pos = 0;
BLI_strncpy(str,"[Constant: ",4096);
value = PyDict_GetItem( self->dict, PyString_FromString("name") );
tempstr = PyString_FromString("name");
value = PyDict_GetItem( self->dict, tempstr );
Py_DECREF(tempstr);
if(value) {
strcat(str, PyString_AsString(value));
} else {

View File

@@ -885,12 +885,20 @@ class Mesh:
@param object: The Blender Object linked to the mesh.
"""
def update():
def update(key=None):
"""
Update display lists after changes to mesh. B{Note}: with changes taking
place for using a directed acyclic graph (DAG) for scene and object
updating, this method may be only temporary and may be removed in future
releases.
@type key: string
@param key: Use this optional argument to write the current vertex
locations to the a shape key. the name must match an existing shape key for this mesh
See L{Mesh.Mesh.key} and L{Key.Key.blocks} to get a list of the named shape keys, setting the active keys is
done from the object with L{Object.Object.pinShape}, L{Object.Object.activeShape}.
@warn: Since Blender 2.42 this function has changed; now it won't recalculate
vertex normals (seen when faces are smooth). See L{Mesh.calcNormals()}.
"""

View File

@@ -465,6 +465,17 @@ class Object:
Value is clamped to [1,len(ob.materials)]. - [0,0] when there is no materials applied to the object.
@type activeMaterial: int
@ivar activeShape: The active shape key index for this object.
The active index is used to select the material to edit in the material buttons,
new data created will also use the active material.
Value is clamped to [1,len(ob.data.key.blocks)]. - [0,0] when there are no keys.
@type activeShape: int
@ivar pinShape: If True, only the activeShape will be displayed.
@type pinShape: bool
@ivar drawSize: The size to display the Empty.
Value clamped to [0.01,10.0].
@type drawSize: float

View File

@@ -386,7 +386,7 @@ void EXPP_allqueue(unsigned short event, short val)
PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args,
int is_scene )
{
PyObject *list = NULL;
PyObject *list = NULL, *tmpstr;
char *eventname = NULL;
int i, event = 0;
@@ -414,15 +414,18 @@ PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args,
event = SCRIPT_ONLOAD;
else if( is_scene && !strcmp( eventname, "OnSave" ) )
event = SCRIPT_ONSAVE;
else
else {
Py_XDECREF(list);
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"invalid event name" );
}
for( i = 0; i < slink->totscript; i++ ) {
if( ( slink->flag[i] == event ) && slink->scripts[i] )
PyList_Append( list,
PyString_FromString( slink->scripts[i]->
name + 2 ) );
if( ( slink->flag[i] == event ) && slink->scripts[i] ) {
tmpstr =PyString_FromString( slink->scripts[i]->name + 2 );
PyList_Append( list, tmpstr );
Py_DECREF(tmpstr);
}
}
return list;

View File

@@ -152,7 +152,8 @@ int updateProperyData( BPy_Property * self )
static int checkValidData_ptr( BPy_Property * self )
{
int length;
//test pointer to see if data was removed (oops)
/* test pointer to see if data was removed (oops) */
/* WARNING!!! - MEMORY LEAK HERE, why not free this??? */
length = MEM_allocN_len( self->property );
if( length != sizeof( bProperty ) ) { //data was freed
self->property = NULL;
@@ -312,11 +313,9 @@ static int Property_compare( BPy_Property * a, BPy_Property * b )
property->
data ) ) );
} else if( py_propB->property->type == PROP_STRING ) {
retval = PyObject_Compare( py_propA->data,
PyString_FromString
( py_propB->
property->
poin ) );
PyObject *tmpstr = PyString_FromString( py_propB->property->poin );
retval = PyObject_Compare( py_propA->data, tmpstr );
Py_DECREF(tmpstr);
}
} else
retval = -1;

View File

@@ -170,7 +170,7 @@ static PyObject *TimeLine_getFramesMarked (BPy_TimeLine *self, PyObject *args) {
PyObject *marker_dict= NULL;
TimeMarker *marker_it= NULL;
PyObject *tmarker= NULL, *pyo= NULL;
PyObject *tmarker= NULL, *pyo= NULL, *tmpstr;
if (!PyArg_ParseTuple (args, "|O", &tmarker))
return EXPP_ReturnPyObjError (PyExc_AttributeError,
@@ -196,13 +196,16 @@ static PyObject *TimeLine_getFramesMarked (BPy_TimeLine *self, PyObject *args) {
for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next){
if (marker_it->frame==frm) {
pyo= PyDict_GetItem ((PyObject*)marker_dict, PyInt_FromLong ((long int)marker_it->frame));
tmpstr = PyString_FromString(marker_it->name);
if (pyo) {
PyList_Append (pyo, PyString_FromString (marker_it->name));
Py_INCREF (pyo);
PyList_Append (pyo, tmpstr);
Py_INCREF(pyo);
}else{
pyo = PyList_New (0);
PyList_Append (pyo, PyString_FromString (marker_it->name));
pyo = PyList_New(0);
PyList_Append (pyo, tmpstr);
}
Py_DECREF(tmpstr);
PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo);
if (pyo) {
Py_DECREF (pyo);
@@ -216,13 +219,16 @@ static PyObject *TimeLine_getFramesMarked (BPy_TimeLine *self, PyObject *args) {
marker_dict= PyDict_New ();
for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) {
pyo=PyDict_GetItem ((PyObject*)marker_dict, PyInt_FromLong ((long int)marker_it->frame));
tmpstr = PyString_FromString(marker_it->name);
if (pyo) {
PyList_Append (pyo, PyString_FromString (marker_it->name));
PyList_Append (pyo, tmpstr);
Py_INCREF (pyo);
}else{
pyo= PyList_New (0);
PyList_Append (pyo, PyString_FromString (marker_it->name));
PyList_Append (pyo, tmpstr);
}
Py_DECREF(tmpstr);
PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo);
if (pyo) {
Py_DECREF (pyo);

View File

@@ -685,8 +685,7 @@ static PyObject *Theme_get( BPy_Theme * self, PyObject * args )
while( type < EXPP_THEME_NUMBEROFTHEMES ) {
PyList_SET_ITEM( ret, type,
PyString_FromString( themes_map[type].
sval ) );
PyString_FromString( themes_map[type].sval ) );
type++;
}