From 62963525ced6a6a286d44eac9cca952aead2ac3f Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 22 Jan 2012 23:15:35 +0000 Subject: [PATCH] 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() --- .../gameengine/Converter/BL_ActionActuator.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index c63b32830b0..1d4edb45242 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -350,6 +350,12 @@ bool BL_ActionActuator::Update(double curtime, bool frame) 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 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, 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* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA 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) {