diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2004-10-31 07:09:19 +0300 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2004-10-31 07:09:19 +0300 |
commit | 13e7525152e9bd7f187bcc89adfd50c5ac4d37ff (patch) | |
tree | 9671e455f0b3783c9e164a006b0f10a0654619ac /source/blender/python/api2_2x/Effect.c | |
parent | e82d208b1c534093b92f0fc95f83dc8c4563345f (diff) |
BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window. It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :). I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'. Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway. Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
Diffstat (limited to 'source/blender/python/api2_2x/Effect.c')
-rw-r--r-- | source/blender/python/api2_2x/Effect.c | 70 |
1 files changed, 52 insertions, 18 deletions
diff --git a/source/blender/python/api2_2x/Effect.c b/source/blender/python/api2_2x/Effect.c index 388f93db0b9..2e3e65e2c77 100644 --- a/source/blender/python/api2_2x/Effect.c +++ b/source/blender/python/api2_2x/Effect.c @@ -133,41 +133,74 @@ PyObject *M_Effect_Get( PyObject * self, PyObject * args ) { /*arguments : string object name int : position of effect in the obj's effect list */ - char *name = 0; + char *name = NULL; Object *object_iter; Effect *eff; BPy_Effect *wanted_eff; - int num, i; + int num = -1, i; + if( !PyArg_ParseTuple( args, "|si", &name, &num ) ) return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expected string int argument" ) ); + object_iter = G.main->object.first; + if( !object_iter ) return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "Scene contains no object" ) ); - if( name ) { + + if( name ) { /* (name, num = -1) - try to find the given object */ + while( object_iter ) { - if( strcmp( name, object_iter->id.name + 2 ) ) { - object_iter = object_iter->id.next; - continue; - } + if( !strcmp( name, object_iter->id.name + 2 ) ) { - if( object_iter->effect.first != NULL ) { - eff = object_iter->effect.first; - for( i = 0; i < num; i++ ) - eff = eff->next; - wanted_eff = - ( BPy_Effect * ) - PyObject_NEW( BPy_Effect, - &Effect_Type ); - wanted_eff->effect = eff; - return ( PyObject * ) wanted_eff; + eff = object_iter->effect.first; /*can be NULL: None will be returned*/ + + if (num >= 0) { /* return effect in given num position if available */ + + for( i = 0; i < num; i++ ) { + if (!eff) break; + eff = eff->next; + } + + if (eff) { + wanted_eff = (BPy_Effect *)PyObject_NEW(BPy_Effect, &Effect_Type); + wanted_eff->effect = eff; + return ( PyObject * ) wanted_eff; + } else { /* didn't find any effect in the given position */ + Py_INCREF(Py_None); + return Py_None; + } + } + + else {/*return a list with all effects linked to the given object*/ + /* this was pointed by Stephen Swaney */ + PyObject *effectlist = PyList_New( 0 ); + + while (eff) { + BPy_Effect *found_eff = (BPy_Effect *)PyObject_NEW(BPy_Effect, + &Effect_Type); + found_eff->effect = eff; + PyList_Append( effectlist, ( PyObject * ) found_eff ); + Py_DECREF((PyObject *)found_eff); /* PyList_Append incref'ed it */ + eff = eff->next; + } + return effectlist; + } } + object_iter = object_iter->id.next; } - } else { + + if (!object_iter) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "no such object"); + } + + else { /* () - return a list with all effects currently in Blender */ PyObject *effectlist = PyList_New( 0 ); + while( object_iter ) { if( object_iter->effect.first != NULL ) { eff = object_iter->effect.first; @@ -180,6 +213,7 @@ PyObject *M_Effect_Get( PyObject * self, PyObject * args ) PyList_Append( effectlist, ( PyObject * ) found_eff ); + Py_DECREF((PyObject *)found_eff); eff = eff->next; } } |