[Bf-blender-cvs] [5ac9e587d48] blender2.8: PyRNA: Ensure changed types creates a new instance
Campbell Barton
noreply at git.blender.org
Tue Aug 1 09:00:12 CEST 2017
Commit: 5ac9e587d48c2d700c10c4eb31fbdd07c858a414
Author: Campbell Barton
Date: Tue Aug 1 17:11:09 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB5ac9e587d48c2d700c10c4eb31fbdd07c858a414
PyRNA: Ensure changed types creates a new instance
Changing lamp type for eg needs to create a new instance.
===================================================================
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 fcd5441b4e1..b9f80b79dde 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -6663,8 +6663,20 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
void **instance = ptr->data ? RNA_struct_instance(ptr) : NULL;
if (instance && *instance) {
pyrna = *instance;
- Py_INCREF(pyrna);
- return (PyObject *)pyrna;
+
+ /* Refine may have changed types after the first instance was created. */
+ if (ptr->type == pyrna->ptr.type) {
+ Py_INCREF(pyrna);
+ return (PyObject *)pyrna;
+ }
+ else {
+ /* Existing users will need to use 'type_recast' method. */
+ Py_DECREF(pyrna);
+ /* Continue as if no instance was made */
+#if 0 /* no need to assign, will be written to next... */
+ *instance = pyrna = NULL;
+#endif
+ }
}
{
More information about the Bf-blender-cvs
mailing list