diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-05-26 10:29:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-05-26 10:29:15 +0400 |
commit | c590dd3e8cd28013262c8a0036a7fef38b99a0a9 (patch) | |
tree | 8256021ecf103f2a0c0d5bd3c9f1ee6a825fbb10 /source/blender/python/intern | |
parent | a98f1f54bfc4a07b55643e111e39ce0e3b80b073 (diff) |
minor ref-counting changes, means new subclasses will get the correct ref count though there are big problems with this still.
Found that subclassing an RNA struct (without even registering or instancing adds a reference to Py_None).
Unlikely a python bug, tested with py2.6 and 3.1
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 7b4d5a2d8ef..ded39482bc7 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1364,7 +1364,18 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) { PointerRNA ptr; PyObject *item; + + Py_INCREF(newclass); + /* Something fishy is going on here, the pointer is set many times but never free'd + * It also is almost always the same type so it looks like the same point is + * being reused when it should not be - must look into this further */ +#if 0 + if (RNA_struct_py_type_get(srna)) + PyObSpit("RNA WAS SET - ", RNA_struct_py_type_get(srna)); + Py_XDECREF(RNA_struct_py_type_get(srna)); // TODO - why does this crash??? +#endif + RNA_struct_py_type_set(srna, (void *)newclass); /* Store for later use */ /* Not 100% needed but useful, @@ -1982,8 +1993,7 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args) BKE_reports_clear(&reports); - pyrna_subtype_set_rna(py_class, srna); - Py_INCREF(py_class); + pyrna_subtype_set_rna(py_class, srna); /* takes a ref to py_class */ Py_RETURN_NONE; } |