diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-05-31 21:44:38 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-05-31 21:44:38 +0400 |
commit | 8e882d0d6118d39d5533eff2d196be4bca4be889 (patch) | |
tree | 40813c58705166ede6755b0bfed323b73e600506 /source/gameengine | |
parent | 759d31d320a5f5acc06444bb49ee58948de2d997 (diff) |
Bug in KX_GameObject.get() and ListValue.get(), wasn't checking if the CValue derived objects could be converted to a PyObject.
so where foo is an int prop,
gameOb.get("foo") == 0, would end up returning a CValue int proxy.
This is more a problem for KX_GameObject since ListValues with python access mostly don't contain ints, strings, floats.
This also wont break games from 2.48 since the .get() function wasn't available.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Expressions/ListValue.cpp | 19 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 9 |
2 files changed, 21 insertions, 7 deletions
diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index c741a6d8809..a0d73c75d60 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -77,8 +77,13 @@ PyObject* listvalue_mapping_subscript(PyObject* self, PyObject* pyindex) if (PyString_Check(pyindex)) { CValue *item = ((CListValue*) list)->FindValue(PyString_AsString(pyindex)); - if (item) - return item->GetProxy(); + if (item) { + PyObject* pyobj = item->ConvertValueToPython(); + if(pyobj) + return pyobj; + else + return item->GetProxy(); + } } else if (PyInt_Check(pyindex)) { @@ -575,9 +580,13 @@ PyObject* CListValue::Pyget(PyObject *args) return NULL; CValue *item = FindValue((const char *)key); - if (item) - return item->GetProxy(); - + if (item) { + PyObject* pyobj = item->ConvertValueToPython(); + if (pyobj) + return pyobj; + else + return item->GetProxy(); + } Py_INCREF(def); return def; } diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 04b1276569e..7f417b325c8 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -2758,8 +2758,13 @@ PyObject* KX_GameObject::Pyget(PyObject *args) if(PyString_Check(key)) { CValue *item = GetProperty(PyString_AsString(key)); - if (item) - return item->GetProxy(); + if (item) { + ret = item->ConvertValueToPython(); + if(ret) + return ret; + else + return item->GetProxy(); + } } if (m_attr_dict && (ret=PyDict_GetItem(m_attr_dict, key))) { |