diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-05 18:55:50 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-05 18:55:50 +0400 |
commit | 3dacfbb23161a1b779c2c4ac0f06431c5adda6a2 (patch) | |
tree | 3259019d0f807562b94051629c2776981f4da694 | |
parent | 033a63f8580227582a9695ebdd78ac0b4322e867 (diff) |
BGE Python API
- action attribute wasnt checking for NULL (own fault)
- KX_Scene getCamera wasnt checking for NULL
- CListValue had asserts for not yet implimented functionality, this would close blender. Better to print an error if the user manages to run this functions (I managed to by CListValue.count([1,2,3]))
-rw-r--r-- | source/gameengine/Converter/BL_ActionActuator.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_ShapeActionActuator.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Expressions/ListValue.cpp | 12 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_SceneActuator.cpp | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 46ad344c5dd..9102c453a16 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -1055,7 +1055,7 @@ int BL_ActionActuator::py_setattro(PyObject *attr, PyObject* value) { PyObject* BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); - return PyString_FromString(self->GetAction()->id.name+2); + return PyString_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); } int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index a6dbf088ee3..d52cc8cfccc 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -886,7 +886,7 @@ PyObject* BL_ShapeActionActuator::PySetType(PyObject* self, PyObject* BL_ShapeActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { BL_ShapeActionActuator* self= static_cast<BL_ShapeActionActuator*>(self_v); - return PyString_FromString(self->GetAction()->id.name+2); + return PyString_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); } int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index 15eb8835b79..d0aec645468 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -430,6 +430,10 @@ bool CListValue::CheckEqual(CValue* first,CValue* second) bool result = false; CValue* eqval = ((CValue*)first)->Calc(VALUE_EQL_OPERATOR,(CValue*)second); + + if (eqval==NULL) + return false; + STR_String txt = eqval->GetText(); eqval->Release(); if (txt=="TRUE") @@ -479,7 +483,7 @@ PyObject* CListValue::Pycount(PyObject* self, PyObject* value) if (checkobj==NULL) { /* in this case just return that there are no items in the list */ PyErr_Clear(); - PyInt_FromLong(0); + return PyInt_FromLong(0); } int numelem = GetCount(); @@ -503,7 +507,8 @@ PyObject* CListValue::Pycount(PyObject* self, PyObject* value) * --------------------------------------------------------------------- */ CValue* CListValue::Calc(VALUE_OPERATOR op,CValue *val) { - assert(false); // todo: implement me! + //assert(false); // todo: implement me! + fprintf(stderr, "CValueList::Calc not yet implimented\n"); return NULL; } @@ -513,7 +518,8 @@ CValue* CListValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue* val) { - assert(false); // todo: implement me! + //assert(false); // todo: implement me! + fprintf(stderr, "CValueList::CalcFinal not yet implimented\n"); return NULL; } diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index f158eb29dd7..e1cd3d45503 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -469,7 +469,7 @@ PyObject* KX_SceneActuator::PyGetCamera(PyObject* self, { ShowDeprecationWarning("getCamera()", "the camera property"); if (m_camera) { - PyString_FromString(m_camera->GetName()); + return PyString_FromString(m_camera->GetName()); } else { Py_RETURN_NONE; |