[Bf-python] Callback types (sorry, got things wrong)
Michael Reimpell
M.Reimpell at tu-bs.de
Mon Jan 17 09:26:20 CET 2005
> I retract that mess, leaving only this snippet
> for adaptation to the callback translation code:
>
> PyObject *retval;
>
> retval=...Call...;
> if(retval)
> Py_DECREF(retval);
> else
> PyErr_Print();
There should be no need for another error check since a failure of
PyArg_ParseTuple already leads to a meaningful error message. The
if( !EXPP_FS_PyCallback )
return;
lines of the getSelectedFile function just catch nested calls to
Blender.Window.ImageSelector/Blender.Window.FileSelector, i.e. Python
callbacks like
def callback(self, f):
Blender.Window.FileSelector(anotherCallback)
return
An implementation that allows nested callbacks would be
static void getSelectedFile( char *name )
{
PyObject * callback;
callback = EXPP_FS_PyCallback;
PyObject_CallFunction( EXPP_FS_PyCallback, "s", name );
if (callback == EXPP_FS_PyCallback) {
Py_DECREF(EXPP_FS_PyCallback);
EXPP_FS_PyCallback = NULL;
} else {
/* nested callback */
Py_DECREF(callback);
}
return;
}
Regards,
Michael
More information about the Bf-python
mailing list