Merge branch 'blender-v4.4-release'

This commit is contained in:
Campbell Barton
2025-02-12 22:39:37 +11:00
2 changed files with 42 additions and 10 deletions

View File

@@ -8015,7 +8015,9 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
/* Done with RNA instance. */
}
/* Return a borrowed reference. */
/**
* \return borrowed reference.
*/
static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dict)
{
/* Assume RNA_struct_py_type_get(srna) was already checked. */
@@ -8043,6 +8045,11 @@ static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dic
* return a borrowed reference. */
static PyObject *bpy_types_dict = nullptr;
/**
* Return the #PyTypeObject or null,
*
* \return borrowed reference.
*/
static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
{
const char *idname = RNA_struct_identifier(srna);
@@ -8100,6 +8107,11 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
return newclass;
}
/**
* Return the #PyTypeObject or null with an exception set.
*
* \return new reference.
*/
static PyObject *pyrna_srna_Subtype(StructRNA *srna)
{
PyObject *newclass = nullptr;
@@ -8109,10 +8121,12 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
newclass = nullptr; /* Nothing to do. */
} /* The class may have already been declared & allocated. */
else if ((newclass = static_cast<PyObject *>(RNA_struct_py_type_get(srna)))) {
/* Add a reference for the return value. */
Py_INCREF(newclass);
} /* Check if bpy_types.py module has the class defined in it. */
} /* Check if `bpy_types.py` module has the class defined in it. */
else if ((newclass = pyrna_srna_ExternalType(srna))) {
pyrna_subtype_set_rna(newclass, srna);
/* Add a reference for the return value. */
Py_INCREF(newclass);
} /* create a new class instance with the C api
* mainly for the purposing of matching the C/RNA type hierarchy */
@@ -8126,7 +8140,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
* )
*/
/* Assume RNA_struct_py_type_get(srna) was already checked. */
/* Assume `RNA_struct_py_type_get(srna)` was already checked. */
PyObject *py_base = pyrna_srna_PyBase(srna);
PyObject *metaclass;
const char *idname = RNA_struct_identifier(srna);
@@ -8190,9 +8204,6 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
if (newclass) {
/* srna owns one, and the other is owned by the caller. */
pyrna_subtype_set_rna(newclass, srna);
/* XXX, adding this back segfaults Blender on load. */
// Py_DECREF(newclass); /* let srna own */
}
else {
/* This should not happen. */
@@ -8217,7 +8228,9 @@ static StructRNA *srna_from_ptr(PointerRNA *ptr)
return ptr->type;
}
/* Always returns a new ref, be sure to decref when done. */
/**
* \return new reference.
*/
static PyObject *pyrna_struct_Subtype(PointerRNA *ptr)
{
return pyrna_srna_Subtype(srna_from_ptr(ptr));
@@ -8228,6 +8241,8 @@ static PyObject *pyrna_struct_Subtype(PointerRNA *ptr)
/**
* A lower level version of #pyrna_struct_CreatePyObject,
* use this when type (`tp`) needs to be set to a non-standard value.
*
* \return new reference.
*/
static PyObject *pyrna_struct_CreatePyObject_from_type(const PointerRNA *ptr,
PyTypeObject *tp,
@@ -9683,7 +9698,20 @@ static void bpy_class_free(void *pyob_ptr)
}
}
#endif
Py_DECREF(self);
#ifdef WITH_PYTHON_MODULE
/* NOTE(@ideasman42) When finalizing the modules that store the types may have been cleared.
* This can cause negative a negative reference count base-classes used by the RNA types
* which asserts in debug builds of Python.
*
* If this is a reference counting issue on Blender's side that should be fixed
* however the problem is quite specific and more a technical issue.
* So skip clearing the reference when finalizing, see: #125376. */
if (!Py_IsFinalizing())
#endif
{
Py_DECREF(self);
}
PyGILState_Release(gilstate);
}