[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10944] trunk/blender/source/blender/ python/BPY_interface.c: Fix a Python memory leak with the armature weakref code.

Ken Hughes khughes at pacific.edu
Sat Jun 16 15:01:10 CEST 2007


Revision: 10944
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10944
Author:   khughes
Date:     2007-06-16 15:01:10 +0200 (Sat, 16 Jun 2007)

Log Message:
-----------
Fix a Python memory leak with the armature weakref code.  setup_armature_weakrefs() wasnt't deallocating the old list, instead just adding a new one to the dictionary. 

Modified Paths:
--------------
    trunk/blender/source/blender/python/BPY_interface.c

Modified: trunk/blender/source/blender/python/BPY_interface.c
===================================================================
--- trunk/blender/source/blender/python/BPY_interface.c	2007-06-16 12:24:41 UTC (rev 10943)
+++ trunk/blender/source/blender/python/BPY_interface.c	2007-06-16 13:01:10 UTC (rev 10944)
@@ -100,7 +100,18 @@
 
 	main_module = PyImport_AddModule( "__main__");
 	if(main_module){
+		PyObject *weakreflink;
 		maindict= PyModule_GetDict(main_module);
+
+		/* check if there is already a dict entry for the armature weakrefs,
+		 * and delete if so before making another one */
+
+		weakreflink= PyDict_GetItemString(maindict,list_name);
+		if( weakreflink != NULL ) {
+			PyDict_DelItemString(maindict,list_name);
+			Py_XDECREF( weakreflink );
+		}
+
 		if (PyDict_SetItemString(maindict, 
 								 list_name, 
 								 PyList_New(0)) == -1){





More information about the Bf-blender-cvs mailing list