[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16075] trunk/blender/source/gameengine/ GameLogic/SCA_PythonController.cpp:

Brecht Van Lommel brechtvanlommel at pandora.be
Wed Aug 13 12:19:48 CEST 2008


Revision: 16075
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16075
Author:   blendix
Date:     2008-08-13 12:19:47 +0200 (Wed, 13 Aug 2008)

Log Message:
-----------

Bugfix: in the game engine, errors in a particular python script caused
somewhat random crashes, which I think was caused by the error print
using python objects that were freed too soon. Now it frees the dictionary
after the print.

Modified Paths:
--------------
    trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp

Modified: trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp	2008-08-13 01:38:13 UTC (rev 16074)
+++ trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp	2008-08-13 10:19:47 UTC (rev 16075)
@@ -273,36 +273,16 @@
 		 * break it by hand, then DECREF (which in this case
 		 * should always ensure excdict is cleared).
 		 */
-/*	PyObject *excdict= myPyDict_Copy(m_pythondictionary);
-	struct _object* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
-		excdict, 
-		excdict
-		);
-	PyDict_Clear(excdict);
-	Py_DECREF(excdict);*/
 
-
-#if 1
 	PyObject *excdict= PyDict_Copy(m_pythondictionary);
 	PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
-		excdict, 
-		excdict
-		);
-	PyDict_Clear(excdict);
-	Py_DECREF(excdict);
-#else
+		excdict, excdict);
 
-	PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
-		m_pythondictionary, 
-		m_pythondictionary
-		);
-
-#endif
-
 	if (resultobj)
 	{
 		Py_DECREF(resultobj);
-	} else
+	}
+	else
 	{
 		// something is wrong, tell the user what went wrong
 		printf("PYTHON SCRIPT ERROR:\n");
@@ -310,6 +290,11 @@
 		//PyRun_SimpleString(m_scriptText.Ptr());
 	}
 
+	// clear after PyErrPrint - seems it can be using
+	// something in this dictionary and crash?
+	PyDict_Clear(excdict);
+	Py_DECREF(excdict);
+
 	m_sCurrentController = NULL;
 }
 





More information about the Bf-blender-cvs mailing list