[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20120] trunk/blender/source/gameengine: More refcount errors spotted by Benoit, one with python getting a list item so scene.objects["OBfoo"] would always mess up refcounts.

Campbell Barton ideasman42 at gmail.com
Sat May 9 19:24:21 CEST 2009


Revision: 20120
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20120
Author:   campbellbarton
Date:     2009-05-09 19:24:21 +0200 (Sat, 09 May 2009)

Log Message:
-----------
More refcount errors spotted by Benoit, one with python getting a list item so scene.objects["OBfoo"] would always mess up refcounts.

Modified Paths:
--------------
    trunk/blender/source/gameengine/Expressions/ListValue.cpp
    trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.cpp

Modified: trunk/blender/source/gameengine/Expressions/ListValue.cpp
===================================================================
--- trunk/blender/source/gameengine/Expressions/ListValue.cpp	2009-05-09 16:59:25 UTC (rev 20119)
+++ trunk/blender/source/gameengine/Expressions/ListValue.cpp	2009-05-09 17:24:21 UTC (rev 20120)
@@ -78,13 +78,15 @@
 		STR_String  index(PyString_AsString(pyindex));
 		CValue *item = ((CListValue*) list)->FindValue(index);
 		if (item)
+		{
+			item->Release(); /* FindValue() AddRef's */ 
 			return item->GetProxy();
-			
+		}
 	}
-	if (PyInt_Check(pyindex))
+	else if (PyInt_Check(pyindex))
 	{
 		int index = PyInt_AsLong(pyindex);
-		return listvalue_buffer_item(self, index);
+		return listvalue_buffer_item(self, index); /* wont add a ref */
 	}
 	
 	PyObject *pyindex_str = PyObject_Repr(pyindex); /* new ref */

Modified: trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.cpp	2009-05-09 16:59:25 UTC (rev 20119)
+++ trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.cpp	2009-05-09 17:24:21 UTC (rev 20120)
@@ -715,6 +715,7 @@
 		mScene->GetObjectList()->FindValue(mMaterial->mapping[i].objconame);
 
 	if(!obj) return;
+	obj->Release(); /* FindValue() AddRef's */
 
 	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
 	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );





More information about the Bf-blender-cvs mailing list