[Bf-blender-cvs] [40a45e393e7] blender2.8: PyAPI: Fix for instancing (Blender owns a reference)
Campbell Barton
noreply at git.blender.org
Wed Jul 26 14:52:21 CEST 2017
Commit: 40a45e393e7651604f97202d21b6bfd5079253b8
Author: Campbell Barton
Date: Wed Jul 26 23:05:00 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB40a45e393e7651604f97202d21b6bfd5079253b8
PyAPI: Fix for instancing (Blender owns a reference)
Also set newly created values to the instance pointer.
===================================================================
M source/blender/python/intern/bpy_rna.c
===================================================================
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index ca1e74ce28e..3c3269853df 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -6657,18 +6657,17 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
if (ptr->data == NULL && ptr->type == NULL) { /* Operator RNA has NULL data */
Py_RETURN_NONE;
}
- else {
- /* New in 2.8x, since not many types support instancing
- * we may want to use a flag to avoid looping over all classes. - campbell */
- {
- void **instance = RNA_struct_instance(ptr);
- if (instance && *instance) {
- pyrna = *instance;
- Py_INCREF(pyrna);
- return (PyObject *)pyrna;
- }
- }
+ /* New in 2.8x, since not many types support instancing
+ * we may want to use a flag to avoid looping over all classes. - campbell */
+ void **instance = RNA_struct_instance(ptr);
+ if (instance && *instance) {
+ pyrna = *instance;
+ Py_INCREF(pyrna);
+ return (PyObject *)pyrna;
+ }
+
+ {
PyTypeObject *tp = (PyTypeObject *)pyrna_struct_Subtype(ptr);
if (tp) {
@@ -6689,6 +6688,12 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
return NULL;
}
+ /* Blender's instance owns a reference (to avoid Python freeing it). */
+ if (instance) {
+ *instance = pyrna;
+ Py_INCREF(pyrna);
+ }
+
pyrna->ptr = *ptr;
#ifdef PYRNA_FREE_SUPPORT
pyrna->freeptr = false;
More information about the Bf-blender-cvs
mailing list