diff options
author | Joseph Gilbert <ascotan@gmail.com> | 2007-01-25 18:19:28 +0300 |
---|---|---|
committer | Joseph Gilbert <ascotan@gmail.com> | 2007-01-25 18:19:28 +0300 |
commit | ea8189389cc779b5229836c0030549be9d0256f3 (patch) | |
tree | d4e2b587e09ddcb3444d90b68add35ed6f4b5385 /source/blender/python/api2_2x/Window.c | |
parent | 8c2af0a5d0a37f3c06a0ccf6938dd3b0bc54fe55 (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/Window.c')
-rw-r--r-- | source/blender/python/api2_2x/Window.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c index de9baec0a81..0bed7d9241d 100644 --- a/source/blender/python/api2_2x/Window.c +++ b/source/blender/python/api2_2x/Window.c @@ -57,7 +57,7 @@ #include "Mathutils.h" #include "constant.h" #include "gen_utils.h" - +#include "Armature.h" /* See Draw.c */ extern int EXPP_disable_force_draw; @@ -890,6 +890,9 @@ static PyObject *M_Window_EditMode( PyObject * self, PyObject * args ) char *undo_str = "From script"; int undo_str_len = 11; int do_undo = 1; + PyObject *maindict = NULL, *armlist = NULL; + PyObject *pyarmature = NULL; + int x; if( !PyArg_ParseTuple( args, "|hs#i", &status, &undo_str, &undo_str_len, &do_undo ) ) @@ -899,14 +902,31 @@ static PyObject *M_Window_EditMode( PyObject * self, PyObject * args ) if( status >= 0 ) { if( status ) { if( !G.obedit ) + //update armatures + maindict= PyModule_GetDict(PyImport_AddModule( "__main__")); + armlist = PyDict_GetItemString(maindict, "armatures"); + for (x = 0; x < PySequence_Size(armlist); x++){ + pyarmature = PyWeakref_GetObject(PySequence_GetItem( armlist, x)); + if (pyarmature != Py_None) + Armature_RebuildEditbones(pyarmature); + } + //enter editmode enter_editmode(0); } else if( G.obedit ) { - if( undo_str_len > 63 ) undo_str[63] = '\0'; /* 64 is max */ - BIF_undo_push( undo_str ); /* This checks user undo settings */ exit_editmode( EM_FREEDATA ); + + //update armatures + maindict= PyModule_GetDict(PyImport_AddModule( "__main__")); + armlist = PyDict_GetItemString(maindict, "armatures"); + for (x = 0; x < PySequence_Size(armlist); x++){ + pyarmature = PyWeakref_GetObject(PySequence_GetItem( armlist, x)); + if (pyarmature != Py_None) + Armature_RebuildBones(pyarmature); + } + } } |