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:
authorJoseph Gilbert <ascotan@gmail.com>2007-01-25 18:19:28 +0300
committerJoseph Gilbert <ascotan@gmail.com>2007-01-25 18:19:28 +0300
commitea8189389cc779b5229836c0030549be9d0256f3 (patch)
treed4e2b587e09ddcb3444d90b68add35ed6f4b5385 /source/blender/python/api2_2x/Armature.c
parent8c2af0a5d0a37f3c06a0ccf6938dd3b0bc54fe55 (diff)
Bug fix for:
[ #5000 ] Changin EditMode in Script wrecks memory Armatures create weakreferences in __main__.__dict__. When Window.Editmode is called, the weaklist it iterated over and armatures are updated.
Diffstat (limited to 'source/blender/python/api2_2x/Armature.c')
-rw-r--r--source/blender/python/api2_2x/Armature.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index f542caeb872..37c28b532d9 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -1111,6 +1111,8 @@ static PyObject *Armature_repr(BPy_Armature *self)
///tp_dealloc
static void Armature_dealloc(BPy_Armature * self)
{
+ if (self->weaklist != NULL)
+ PyObject_ClearWeakRefs((PyObject *) self);
Py_DECREF(self->Bones);
Armature_Type.tp_free(self);
return;
@@ -1137,12 +1139,12 @@ PyTypeObject Armature_Type = {
0, //tp_getattro
0, //tp_setattro
0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
+ Py_TPFLAGS_DEFAULT| Py_TPFLAGS_HAVE_WEAKREFS, //tp_flags
BPy_Armature_doc, //tp_doc
0, //tp_traverse
0, //tp_clear
0, //tp_richcompare
- 0, //tp_weaklistoffset
+ offsetof(BPy_Armature, weaklist), //tp_weaklistoffset
0, //tp_iter
0, //tp_iternext
BPy_Armature_methods, //tp_methods
@@ -1328,14 +1330,27 @@ struct PyMethodDef M_Armature_methods[] = {
{NULL, NULL, 0, NULL}
};
//------------------VISIBLE PROTOTYPE IMPLEMENTATION-----------------------
+//------------------------Armature_RebuildEditbones (internal)
+PyObject * Armature_RebuildEditbones(PyObject *pyarmature)
+{
+ return Armature_makeEditable((BPy_Armature*)pyarmature);
+}
+
+//------------------------Armature_RebuildBones (internal)
+PyObject *Armature_RebuildBones(PyObject *pyarmature)
+{
+ return Armature_update((BPy_Armature*)pyarmature);
+}
//-----------------(internal)
//Converts a bArmature to a PyArmature
PyObject *PyArmature_FromArmature(struct bArmature *armature)
{
BPy_Armature *py_armature = NULL;
+ PyObject *maindict = NULL, *armdict = NULL, *weakref = NULL;
//create armature type
py_armature = (BPy_Armature*)Armature_Type.tp_alloc(&Armature_Type, 0); //*new*
+ py_armature->weaklist = NULL; //init the weaklist
if (!py_armature)
goto RuntimeError;
py_armature->armature = armature;
@@ -1345,6 +1360,14 @@ PyObject *PyArmature_FromArmature(struct bArmature *armature)
if (!py_armature->Bones)
goto RuntimeError;
+ //put a weakreference in __main__
+ maindict= PyModule_GetDict(PyImport_AddModule( "__main__"));
+ armdict = PyDict_GetItemString(maindict, "armatures");
+ weakref = PyWeakref_NewProxy((PyObject*)py_armature, Py_None);
+ if (PyList_Append(armdict, weakref) == -1){
+ goto RuntimeError;
+ }
+
return (PyObject *) py_armature;
RuntimeError: