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 | |
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')
-rw-r--r-- | source/blender/python/api2_2x/Ipo.c | 23 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Ipo.py | 3 |
2 files changed, 13 insertions, 13 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; diff --git a/source/blender/python/api2_2x/doc/Ipo.py b/source/blender/python/api2_2x/doc/Ipo.py index 8d2ee47b324..0449f037dfa 100644 --- a/source/blender/python/api2_2x/doc/Ipo.py +++ b/source/blender/python/api2_2x/doc/Ipo.py @@ -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, |