-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 )
|
||||
{
|
||||
int param = 0; /* numeric curve name constant */
|
||||
int ok = 0;
|
||||
int ipofound = 0;
|
||||
int ok;
|
||||
char *cur_name = 0; /* input arg: curve name */
|
||||
Ipo *ipo = 0;
|
||||
IpoCurve *icu = 0;
|
||||
@@ -851,20 +850,14 @@ static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args )
|
||||
|
||||
while( link ) {
|
||||
ipo = ( Ipo * ) link;
|
||||
if( ipo == self->ipo ) {
|
||||
ipofound = 1;
|
||||
if( ipo == self->ipo )
|
||||
break;
|
||||
}
|
||||
link = link->next;
|
||||
}
|
||||
|
||||
if( ipo && ipofound ) {
|
||||
/* ok. continue */
|
||||
} else { /* runtime error here: our ipo not found */
|
||||
return ( EXPP_ReturnPyObjError
|
||||
( PyExc_RuntimeError, "Ipo not found" ) );
|
||||
}
|
||||
|
||||
if( !link )
|
||||
return EXPP_ReturnPyObjError
|
||||
( PyExc_RuntimeError, "Ipo not found" );
|
||||
|
||||
/*
|
||||
depending on the block type,
|
||||
@@ -913,6 +906,12 @@ static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args )
|
||||
return EXPP_ReturnPyObjError
|
||||
( 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 */
|
||||
icu = MEM_callocN(sizeof(IpoCurve), "Python added ipocurve");
|
||||
icu->blocktype= ipo->blocktype;
|
||||
|
||||
@@ -107,7 +107,8 @@ class Ipo:
|
||||
|
||||
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.
|
||||
2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref,
|
||||
Alpha, Emit, Amb, Spec, Hard, SpTra, Ior, Mode, HaSize, Translu,
|
||||
|
||||
Reference in New Issue
Block a user