[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20539] trunk/blender/source/gameengine: Bug in KX_GameObject.get() and ListValue.get(), wasn' t checking if the CValue derived objects could be converted to a PyObject.
Campbell Barton
ideasman42 at gmail.com
Sun May 31 19:44:39 CEST 2009
Revision: 20539
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20539
Author: campbellbarton
Date: 2009-05-31 19:44:38 +0200 (Sun, 31 May 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/gameengine/Expressions/ListValue.cpp
trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
Modified: trunk/blender/source/gameengine/Expressions/ListValue.cpp
===================================================================
--- trunk/blender/source/gameengine/Expressions/ListValue.cpp 2009-05-31 17:20:57 UTC (rev 20538)
+++ trunk/blender/source/gameengine/Expressions/ListValue.cpp 2009-05-31 17:44:38 UTC (rev 20539)
@@ -77,8 +77,13 @@
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 @@
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;
}
Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2009-05-31 17:20:57 UTC (rev 20538)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2009-05-31 17:44:38 UTC (rev 20539)
@@ -2758,8 +2758,13 @@
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))) {
More information about the Bf-blender-cvs
mailing list