diff options
author | Jacques Guignot <guignot@wanadoo.fr> | 2003-07-22 01:58:13 +0400 |
---|---|---|
committer | Jacques Guignot <guignot@wanadoo.fr> | 2003-07-22 01:58:13 +0400 |
commit | 9a5cf3cb6679c111794856f038231eab1976826e (patch) | |
tree | 30ad57d2d7e01fdc0c44b9644e988d4ed1880301 | |
parent | bf23ed161e7a1ce9f5362a826e288d17edbf8d6a (diff) |
modified the function getattr, which crashed blender when someone tried to access a NULL field. This function returns now PyNone.
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 16c192be1a7..b08d35b31a7 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -1324,26 +1324,35 @@ static PyObject* Object_getAttr (BPy_Object *obj, char *name) return (PyFloat_FromDouble (ika->effg[1])); case 'Z': return (PyFloat_FromDouble (ika->effg[2])); - default: - /* Do we need to display a sensible error message here? */ - return (NULL); + default: + /* Do we need to display a sensible error message here? */ + return (NULL); } } return (NULL); } if (StringEqual (name, "Layer")) - return (PyInt_FromLong(object->lay)); + return (PyInt_FromLong(object->lay)); if (StringEqual (name, "parent")) + if (object->parent) return (Object_CreatePyObject (object->parent)); + else + { + Py_INCREF (Py_None); + return (Py_None); + } + if (StringEqual (name, "track")) - return (Object_CreatePyObject (object->track)); + return (Object_CreatePyObject (object->track)); if (StringEqual (name, "data")) - return (Object_getData (obj)); + return (Object_getData (obj)); if (StringEqual (name, "ipo")) { if (obj->ipo == NULL) { - obj->ipo = Ipo_CreatePyObject (object->ipo); + + Py_INCREF (Py_None); + return (Py_None); } else { |