==Python API==
Bugfix, Space Handlers could crash blender when used with armatures. also fixed some possible bugs in other areas.
This commit is contained in:
@@ -1938,6 +1938,7 @@ void BPY_do_pyscript( ID * id, short event )
|
||||
scriptlink = ID_getScriptlink( id );
|
||||
|
||||
if( scriptlink && scriptlink->totscript ) {
|
||||
PyObject *value;
|
||||
PyObject *dict;
|
||||
PyObject *ret;
|
||||
int index, during_slink = during_scriptlink( );
|
||||
@@ -1947,7 +1948,13 @@ void BPY_do_pyscript( ID * id, short event )
|
||||
return;
|
||||
|
||||
if( !setup_armature_weakrefs()){
|
||||
printf("Oops - weakref dict\n");
|
||||
printf("Oops - weakref dict, this is a bug\n");
|
||||
return;
|
||||
}
|
||||
|
||||
value = GetPyObjectFromID( id );
|
||||
if( !value){
|
||||
printf("Oops - could not get a valid python object for Blender.link, this is a bug\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1959,8 +1966,8 @@ void BPY_do_pyscript( ID * id, short event )
|
||||
|
||||
/* set globals in Blender module to identify scriptlink */
|
||||
EXPP_dict_set_item_str( g_blenderdict, "bylink", EXPP_incr_ret_True() );
|
||||
EXPP_dict_set_item_str( g_blenderdict, "link",
|
||||
GetPyObjectFromID( id ) );
|
||||
|
||||
EXPP_dict_set_item_str( g_blenderdict, "link", value );
|
||||
EXPP_dict_set_item_str( g_blenderdict, "event",
|
||||
PyString_FromString( event_to_name
|
||||
( event ) ) );
|
||||
@@ -2178,6 +2185,11 @@ int BPY_do_spacehandlers( ScrArea *sa, unsigned short event,
|
||||
disable_where_scriptlink( (short)during_slink );
|
||||
}
|
||||
|
||||
if( !setup_armature_weakrefs()){
|
||||
printf("Oops - weakref dict, this is a bug\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* set globals in Blender module to identify space handler scriptlink */
|
||||
EXPP_dict_set_item_str(g_blenderdict, "bylink", EXPP_incr_ret_True());
|
||||
/* unlike normal scriptlinks, here Blender.link is int (space event type) */
|
||||
|
||||
@@ -1202,6 +1202,10 @@ static PyObject *M_Armature_Get(PyObject * self, PyObject * args)
|
||||
data = G.main->armature.first; //get the first data ID from the armature library
|
||||
while (data){
|
||||
py_armature = Armature_CreatePyObject(data); //*new*
|
||||
if (!py_armature) {
|
||||
EXPP_decr2(seq, dict);
|
||||
return NULL; /* error is set from Armature_CreatePyObject */
|
||||
}
|
||||
sprintf(buffer, "%s", ((bArmature*)data)->id.name +2);
|
||||
if(PyDict_SetItemString(dict, buffer, py_armature) == -1){ //add to dictionary
|
||||
EXPP_decr3(seq, dict, py_armature);
|
||||
@@ -1219,6 +1223,11 @@ static PyObject *M_Armature_Get(PyObject * self, PyObject * args)
|
||||
data = find_id("AR", name); //get data from library
|
||||
if (data != NULL){
|
||||
py_armature = Armature_CreatePyObject(data); //*new*
|
||||
if (!py_armature) {
|
||||
EXPP_decr2(seq, dict);
|
||||
return NULL; /* error is set from Armature_CreatePyObject */
|
||||
}
|
||||
|
||||
if(PyDict_SetItemString(dict, name, py_armature) == -1){ //add to dictionary
|
||||
EXPP_decr3(seq, dict, py_armature);
|
||||
goto RuntimeError;
|
||||
|
||||
Reference in New Issue
Block a user