[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43626] trunk/blender/source/gameengine/ Converter/BL_ActionActuator.cpp: Fix for "[#29911] Crash on reading BL_ActionActuator.channelNames"

Mitchell Stokes mogurijin at gmail.com
Mon Jan 23 00:15:36 CET 2012


Revision: 43626
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43626
Author:   moguri
Date:     2012-01-22 23:15:35 +0000 (Sun, 22 Jan 2012)
Log Message:
-----------
Fix for "[#29911] Crash on reading BL_ActionActuator.channelNames"

The crash occurred when an action actuator was attached to a non-armature object because objects that aren't armatures do not have pose data. A NotImplementedError is now raised if someone tries to access any of the following with an action actuator attached to a non-armature object:

BL_ActionActuator.channelNames
BL_ActionActuator.getChannel()
BL_ActionActuator.setChannel()

Modified Paths:
--------------
    trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp

Modified: trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp	2012-01-22 23:13:24 UTC (rev 43625)
+++ trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp	2012-01-22 23:15:35 UTC (rev 43626)
@@ -350,6 +350,12 @@
 PyObject* BL_ActionActuator::PyGetChannel(PyObject* value)
 {
 	const char *string= _PyUnicode_AsString(value);
+
+	if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
+	{
+		PyErr_SetString(PyExc_NotImplementedError, "actuator.getChannel(): Only armatures support channels");
+		return NULL;
+	}
 	
 	if (!string) {
 		PyErr_SetString(PyExc_TypeError, "expected a single string");
@@ -414,6 +420,12 @@
 	PyObject *pymat= NULL;
 	PyObject *pyloc= NULL, *pysize= NULL, *pyquat= NULL;
 	bPoseChannel *pchan;
+
+	if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
+	{
+		PyErr_SetString(PyExc_NotImplementedError, "actuator.setChannel(): Only armatures support channels");
+		return NULL;
+	}
 	
 	if(PyTuple_Size(args)==2) {
 		if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix
@@ -574,6 +586,12 @@
 	PyObject *ret= PyList_New(0);
 	PyObject *item;
 	
+	if (self->GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
+	{
+		PyErr_SetString(PyExc_NotImplementedError, "actuator.channelNames: Only armatures support channels");
+		return NULL;
+	}
+
 	bPose *pose= ((BL_ArmatureObject*)self->GetParent())->GetOrigPose();
 	
 	if(pose) {



More information about the Bf-blender-cvs mailing list