diff options
author | Ken Hughes <khughes@pacific.edu> | 2005-10-25 08:46:49 +0400 |
---|---|---|
committer | Ken Hughes <khughes@pacific.edu> | 2005-10-25 08:46:49 +0400 |
commit | edd998c042f3beaa8d26bc11c2e160a2751c3dbc (patch) | |
tree | 30e51233aa3457368ca1c1dfea459971ef104270 /source/blender/python/api2_2x/Ipo.c | |
parent | 42127966288d44509ff12463bfc0dd2de9de07d8 (diff) |
-Bugfix #3254: Ipo.addCurve() didn't check if curve already existed before
creating (reported by Toni)
Diffstat (limited to 'source/blender/python/api2_2x/Ipo.c')
-rw-r--r-- | source/blender/python/api2_2x/Ipo.c | 23 |
1 files changed, 11 insertions, 12 deletions
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; |