Index: Window.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Window.c,v retrieving revision 1.24 diff -u -r1.24 Window.c --- Window.c 5 Dec 2004 04:01:57 -0000 1.24 +++ Window.c 16 Jan 2005 11:32:55 -0000 @@ -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 * * ***** 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. */ @@ -455,8 +455,9 @@ if( !EXPP_FS_PyCallback ) return; - PyObject_CallFunction( ( PyObject * ) EXPP_FS_PyCallback, "s", name ); + PyObject_CallFunction( EXPP_FS_PyCallback, "s", name ); + Py_DECREF(EXPP_FS_PyCallback); EXPP_FS_PyCallback = NULL; return; @@ -470,12 +471,12 @@ 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 +515,13 @@ 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