From edd998c042f3beaa8d26bc11c2e160a2751c3dbc Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Tue, 25 Oct 2005 04:46:49 +0000 Subject: -Bugfix #3254: Ipo.addCurve() didn't check if curve already existed before creating (reported by Toni) --- source/blender/python/api2_2x/Ipo.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'source/blender/python/api2_2x/Ipo.c') diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c index fbb03933fc8..02a7749c59d 100644 --- a/source/blender/python/api2_2x/Ipo.c +++ b/source/blender/python/api2_2x/Ipo.c @@ -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; -- cgit v1.2.3