diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2012-01-23 03:15:35 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2012-01-23 03:15:35 +0400 |
commit | 62963525ced6a6a286d44eac9cca952aead2ac3f (patch) | |
tree | dada375a4675c18dd4bd2b2107b609a140a431f0 /source/gameengine | |
parent | a004257e4787930f8a67a31e5c442abfa1a333dd (diff) |
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()
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Converter/BL_ActionActuator.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
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) { |