Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-08-25 23:05:18 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-08-25 23:05:18 +0400
commite7a2a175df006c75c859a861cb595e87531115c4 (patch)
tree6311d75bb3f6121ff8bc865d7698c6b4f7142323 /source/blender/python/api2_2x/Armature.c
parent0cfe5527b0741ee644064bd70fd465e8d187ab9b (diff)
getting the armature twice would cause a weakref error and crash after 2-4 runs..
data = arm_ob.data bones = arm_ob.data.bones.values() Fixed by returning existing armatures if they exist in the weakref list. tested with FBX and BVH support.
Diffstat (limited to 'source/blender/python/api2_2x/Armature.c')
-rw-r--r--source/blender/python/api2_2x/Armature.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index e00ec339063..0a616e2b9fe 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -1318,7 +1318,28 @@ PyObject *Armature_CreatePyObject(struct bArmature *armature)
PyObject *maindict = NULL, *weakref = NULL;
PyObject *armlist = NULL; /* list of armature weak refs */
char *list_name = ARM_WEAKREF_LIST_NAME;
+ int i;
+
+ //put a weakreference in __main__
+ maindict= PyModule_GetDict(PyImport_AddModule( "__main__"));
+
+ armlist = PyDict_GetItemString(maindict, list_name);
+ if(!armlist) {
+ printf("Oops - can't get the armature weakref list\n");
+ goto RuntimeError;
+ }
+
+ /* see if we alredy have it */
+ for (i=0; i< PyList_Size(armlist); i++) {
+ py_armature = (BPy_Armature *)PyWeakref_GetObject(PyList_GET_ITEM(armlist, i));
+ if (BPy_Armature_Check(py_armature) && py_armature->armature == armature) {
+ Py_INCREF(py_armature);
+ /*printf("reusing armature\n");*/
+ return (PyObject *)py_armature;
+ }
+ }
+
/*create armature type*/
py_armature = PyObject_NEW( BPy_Armature, &Armature_Type );
@@ -1336,19 +1357,13 @@ PyObject *Armature_CreatePyObject(struct bArmature *armature)
printf("Oops - creating armature.bones\n");
goto RuntimeError;
}
-
- //put a weakreference in __main__
- maindict= PyModule_GetDict(PyImport_AddModule( "__main__"));
-
- armlist = PyDict_GetItemString(maindict, list_name);
- if( armlist){
- weakref = PyWeakref_NewProxy((PyObject*)py_armature, arm_weakref_callback_weakref_dealloc__pyfunc);
- if (PyList_Append(armlist, weakref) == -1){
- printf("Oops - list-append failed\n");
- goto RuntimeError;
- }
- Py_DECREF(weakref);
+
+ weakref = PyWeakref_NewProxy((PyObject*)py_armature, arm_weakref_callback_weakref_dealloc__pyfunc);
+ if (PyList_Append(armlist, weakref) == -1){
+ printf("Oops - list-append failed\n");
+ goto RuntimeError;
}
+ Py_DECREF(weakref);
return (PyObject *) py_armature;