PyAPI: Fix for instancing (Blender owns a reference)
Also set newly created values to the instance pointer.
This commit is contained in:
@@ -6657,18 +6657,17 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
|
|||||||
if (ptr->data == NULL && ptr->type == NULL) { /* Operator RNA has NULL data */
|
if (ptr->data == NULL && ptr->type == NULL) { /* Operator RNA has NULL data */
|
||||||
Py_RETURN_NONE;
|
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);
|
PyTypeObject *tp = (PyTypeObject *)pyrna_struct_Subtype(ptr);
|
||||||
|
|
||||||
if (tp) {
|
if (tp) {
|
||||||
@@ -6689,6 +6688,12 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Blender's instance owns a reference (to avoid Python freeing it). */
|
||||||
|
if (instance) {
|
||||||
|
*instance = pyrna;
|
||||||
|
Py_INCREF(pyrna);
|
||||||
|
}
|
||||||
|
|
||||||
pyrna->ptr = *ptr;
|
pyrna->ptr = *ptr;
|
||||||
#ifdef PYRNA_FREE_SUPPORT
|
#ifdef PYRNA_FREE_SUPPORT
|
||||||
pyrna->freeptr = false;
|
pyrna->freeptr = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user