diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-08-22 21:06:10 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-08-22 21:06:10 +0400 |
commit | 215f80361cfeb294aed9e93cb6899d18c28d8bbf (patch) | |
tree | b4395a2a2354fc8940d931fd77ad84557db53161 /source/blender/python | |
parent | 98e9ddbf5b2b9dcf8a6a2440126f928d4394a5f4 (diff) |
bpy's __rna__ attribute doesnt work as it should, since the parent classes __rna__ overrides the subtypes.
For now have pyrna_struct_as_srna look in the dict first for __rna__ before using PyDict_GetItemString.
Somehow __rna__ is not calling the pyrna_struct_getattro function, python find it first.
The only relyable way to get the rna from python currently is.
bpy.types.SomeType.__dict__['__rna__']
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index bece114d8bd..31648037346 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -2655,8 +2655,17 @@ PyObject *BPY_rna_props( void ) static StructRNA *pyrna_struct_as_srna(PyObject *self) { - BPy_StructRNA *py_srna= (BPy_StructRNA*)PyObject_GetAttrString(self, "__rna__"); + BPy_StructRNA *py_srna; StructRNA *srna; + + /* ack, PyObject_GetAttrString wont look up this types tp_dict first :/ */ + if(PyType_Check(self)) { + py_srna = (BPy_StructRNA *)PyDict_GetItemString(((PyTypeObject *)self)->tp_dict, "__rna__"); + Py_XINCREF(py_srna); + } + + if(py_srna==NULL) + py_srna = (BPy_StructRNA*)PyObject_GetAttrString(self, "__rna__"); if(py_srna==NULL) { PyErr_SetString(PyExc_SystemError, "internal error, self had no __rna__ attribute, should never happen."); |