Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-08-01 10:11:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-08-01 10:14:09 +0300
commit5ac9e587d48c2d700c10c4eb31fbdd07c858a414 (patch)
tree3da0379872850739fba8506399422503798239df /source
parenta108d81af966e4d6b2f29fadcfb28b4084276ad1 (diff)
PyRNA: Ensure changed types creates a new instance
Changing lamp type for eg needs to create a new instance.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/intern/bpy_rna.c16
1 files changed, 14 insertions, 2 deletions
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
+ }
}
{