diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2005-01-22 05:48:03 +0300 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2005-01-22 05:48:03 +0300 |
commit | 1da3b9f517103f6e04312faf08ca7c71edf7d0dd (patch) | |
tree | 62fe0e630b657710eff98a11499d1a61ef77fb5e /source/blender/python/api2_2x/Window.c | |
parent | 5822d4601d7cf93155442ab653b54d3e3c03cae5 (diff) |
BPython:
- Stephane Soppera added long missed support for edge data in Blender.NMesh + related doc;
- Michael Reimpell improved script registration (fixes bug report #2160) and the file and image selectors in Blender.Window (improved with suggestions from Yann Vernier). They now suppport methods as callbacks;
- World.get/setMode were not registered, so could not be directly called (reported by Ken Hughes). Still needs some work to improve things, including docs.
Scripts:
- Jean-Michel Soler updated his texture baker based on input from Appolux;
- Campbell and Jean-Michel improved the bvh importer: faster, better float units scaling (by Campbell); supports Poser 3.01 files (by jms).
Thanks guys!
Diffstat (limited to 'source/blender/python/api2_2x/Window.c')
-rw-r--r-- | source/blender/python/api2_2x/Window.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c index 28a17d08936..750f7ef30b3 100644 --- a/source/blender/python/api2_2x/Window.c +++ b/source/blender/python/api2_2x/Window.c @@ -25,7 +25,7 @@ * * This is a new part of Blender. * - * Contributor(s): Willian P. Germano, Tom Musgrove + * Contributor(s): Willian P. Germano, Tom Musgrove, Michael Reimpell, Yann Vernier * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ @@ -68,7 +68,7 @@ extern int EXPP_disable_force_draw; /* Callback used by the file and image selector access functions */ -static PyObject *( *EXPP_FS_PyCallback ) ( PyObject * arg ) = NULL; +static PyObject *EXPP_FS_PyCallback = NULL; /*****************************************************************************/ /* Python API function prototypes for the Window module. */ @@ -452,13 +452,24 @@ static PyObject *M_Window_QRedrawAll( PyObject * self, PyObject * args ) static void getSelectedFile( char *name ) { - if( !EXPP_FS_PyCallback ) - return; - - PyObject_CallFunction( ( PyObject * ) EXPP_FS_PyCallback, "s", name ); - - EXPP_FS_PyCallback = NULL; - + PyObject *callback; + PyObject *result; + + callback = EXPP_FS_PyCallback; + result = PyObject_CallFunction( EXPP_FS_PyCallback, "s", name ); + if ((!result) && (G.f & G_DEBUG)) { + fprintf(stderr, "BPy error: Callback call failed!\n"); + } + Py_XDECREF(result); + /* Catch changes of EXPP_FS_PyCallback during the callback call + * due to calls to Blender.Window.FileSelector or + * Blender.Window.ImageSelector inside the python callback. */ + if (callback == EXPP_FS_PyCallback) { + Py_DECREF(EXPP_FS_PyCallback); + EXPP_FS_PyCallback = NULL; + } else { + Py_DECREF(callback); + } return; } @@ -470,12 +481,12 @@ static PyObject *M_Window_FileSelector( PyObject * self, PyObject * args ) Script *script = G.main->script.last; int startspace = 0; - if( !PyArg_ParseTuple( args, "O!|ss", - &PyFunction_Type, &EXPP_FS_PyCallback, &title, - &filename ) ) + if( (!PyArg_ParseTuple( args, "O|ss", &EXPP_FS_PyCallback, &title, &filename ) ) + || (!PyCallable_Check(EXPP_FS_PyCallback))) return EXPP_ReturnPyObjError( PyExc_AttributeError, "\nexpected a callback function (and optionally one or two strings) " "as argument(s)" ); + Py_XINCREF(EXPP_FS_PyCallback); /* trick: we move to a spacescript because then the fileselector will properly * unset our SCRIPT_FILESEL flag when the user chooses a file or cancels the @@ -514,13 +525,13 @@ static PyObject *M_Window_ImageSelector( PyObject * self, PyObject * args ) Script *script = G.main->script.last; int startspace = 0; - if( !PyArg_ParseTuple( args, "O!|ss", - &PyFunction_Type, &EXPP_FS_PyCallback, &title, - &filename ) ) + if( !PyArg_ParseTuple( args, "O|ss", &EXPP_FS_PyCallback, &title, &filename ) + || (!PyCallable_Check(EXPP_FS_PyCallback))) return ( EXPP_ReturnPyObjError ( PyExc_AttributeError, "\nexpected a callback function (and optionally one or two strings) " "as argument(s)" ) ); + Py_XINCREF(EXPP_FS_PyCallback); /* trick: we move to a spacescript because then the fileselector will properly * unset our SCRIPT_FILESEL flag when the user chooses a file or cancels the |