-Bugfix #3254: Ipo.addCurve() didn't check if curve already existed before
creating (reported by Toni)
This commit is contained in:
@@ -834,8 +834,7 @@ static int Ipo_obIcuName( char *s, int *param )
|
|||||||
static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args )
|
static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args )
|
||||||
{
|
{
|
||||||
int param = 0; /* numeric curve name constant */
|
int param = 0; /* numeric curve name constant */
|
||||||
int ok = 0;
|
int ok;
|
||||||
int ipofound = 0;
|
|
||||||
char *cur_name = 0; /* input arg: curve name */
|
char *cur_name = 0; /* input arg: curve name */
|
||||||
Ipo *ipo = 0;
|
Ipo *ipo = 0;
|
||||||
IpoCurve *icu = 0;
|
IpoCurve *icu = 0;
|
||||||
@@ -851,20 +850,14 @@ static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args )
|
|||||||
|
|
||||||
while( link ) {
|
while( link ) {
|
||||||
ipo = ( Ipo * ) link;
|
ipo = ( Ipo * ) link;
|
||||||
if( ipo == self->ipo ) {
|
if( ipo == self->ipo )
|
||||||
ipofound = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
link = link->next;
|
link = link->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ipo && ipofound ) {
|
if( !link )
|
||||||
/* ok. continue */
|
return EXPP_ReturnPyObjError
|
||||||
} else { /* runtime error here: our ipo not found */
|
( PyExc_RuntimeError, "Ipo not found" );
|
||||||
return ( EXPP_ReturnPyObjError
|
|
||||||
( PyExc_RuntimeError, "Ipo not found" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
depending on the block type,
|
depending on the block type,
|
||||||
@@ -913,6 +906,12 @@ static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args )
|
|||||||
return EXPP_ReturnPyObjError
|
return EXPP_ReturnPyObjError
|
||||||
( PyExc_NameError, "curve name was invalid" );
|
( PyExc_NameError, "curve name was invalid" );
|
||||||
|
|
||||||
|
/* see if the curve already exists */
|
||||||
|
for( icu = ipo->curve.first; icu; icu = icu->next )
|
||||||
|
if( icu->adrcode == param )
|
||||||
|
return EXPP_ReturnPyObjError( PyExc_ValueError,
|
||||||
|
"Ipo curve already exists" );
|
||||||
|
|
||||||
/* create the new ipo curve */
|
/* create the new ipo curve */
|
||||||
icu = MEM_callocN(sizeof(IpoCurve), "Python added ipocurve");
|
icu = MEM_callocN(sizeof(IpoCurve), "Python added ipocurve");
|
||||||
icu->blocktype= ipo->blocktype;
|
icu->blocktype= ipo->blocktype;
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ class Ipo:
|
|||||||
|
|
||||||
def addCurve(curvename):
|
def addCurve(curvename):
|
||||||
"""
|
"""
|
||||||
Add a new curve to the IPO object. The possible values for 'curvename' are:
|
Add a new curve to the IPO object. Throws an exception if the curve
|
||||||
|
already exists in the IPO. The possible values for 'curvename' are:
|
||||||
1. Camera Ipo: Lens, ClSta, ClEnd, Apert, FDist.
|
1. Camera Ipo: Lens, ClSta, ClEnd, Apert, FDist.
|
||||||
2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref,
|
2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref,
|
||||||
Alpha, Emit, Amb, Spec, Hard, SpTra, Ior, Mode, HaSize, Translu,
|
Alpha, Emit, Amb, Spec, Hard, SpTra, Ior, Mode, HaSize, Translu,
|
||||||
|
|||||||
Reference in New Issue
Block a user