Merge branch 'blender-v4.5-release'
This commit is contained in:
@@ -901,6 +901,10 @@ struct BlenderRNA;
|
||||
* order to make them definable through RNA.
|
||||
*/
|
||||
struct ExtensionRNA {
|
||||
/**
|
||||
* \note For Python types this holds the Python class but does *not* own a reference.
|
||||
* The same value is typically stored in `srna->py_type` which does own a reference.
|
||||
*/
|
||||
void *data;
|
||||
StructRNA *srna;
|
||||
StructCallbackFunc call;
|
||||
|
||||
@@ -782,12 +782,14 @@ void RNA_define_fallback_property_update(int noteflag, const char *updatefunc)
|
||||
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext)
|
||||
{
|
||||
#ifdef RNA_RUNTIME
|
||||
rna_ext->free(rna_ext->data); /* Decrefs the PyObject that the `srna` owns. */
|
||||
rna_ext->free(rna_ext->data);
|
||||
RNA_struct_blender_type_set(srna, nullptr); /* FIXME: this gets accessed again. */
|
||||
|
||||
/* nullptr the srna's value so RNA_struct_free won't complain of a leak */
|
||||
RNA_struct_py_type_set(srna, nullptr);
|
||||
|
||||
/* Decrease the reference and set to null so #RNA_struct_free doesn't warn of a leak. */
|
||||
if (srna->py_type) {
|
||||
BPY_DECREF(srna->py_type);
|
||||
RNA_struct_py_type_set(srna, nullptr);
|
||||
}
|
||||
#else
|
||||
(void)srna;
|
||||
(void)rna_ext;
|
||||
|
||||
@@ -9754,7 +9754,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
|
||||
return err;
|
||||
}
|
||||
|
||||
static void bpy_class_free(void *pyob_ptr)
|
||||
/**
|
||||
* \param decref: When true, decrease the reference.
|
||||
*/
|
||||
static void bpy_class_free_ex(PyObject *self, bool decref)
|
||||
{
|
||||
#ifdef WITH_PYTHON_MODULE
|
||||
/* This can happen when Python has exited before all Blender's RNA types have been freed.
|
||||
@@ -9773,8 +9776,6 @@ static void bpy_class_free(void *pyob_ptr)
|
||||
|
||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||
|
||||
PyObject *self = (PyObject *)pyob_ptr;
|
||||
|
||||
/* Breaks re-registering classes. */
|
||||
// PyDict_Clear(((PyTypeObject *)self)->tp_dict);
|
||||
|
||||
@@ -9794,23 +9795,22 @@ static void bpy_class_free(void *pyob_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
{
|
||||
if (decref) {
|
||||
Py_DECREF(self);
|
||||
}
|
||||
|
||||
PyGILState_Release(gilstate);
|
||||
}
|
||||
|
||||
static void bpy_class_free(void *pyob_ptr)
|
||||
{
|
||||
/* Don't remove a reference because the argument passed in is from #ExtensionRNA::data
|
||||
* which doesn't own the reference.
|
||||
* This value is typically stored in #StructRNA::py_type which is handled separately. */
|
||||
bool decref = false;
|
||||
bpy_class_free_ex(static_cast<PyObject *>(pyob_ptr), decref);
|
||||
}
|
||||
|
||||
/**
|
||||
* \return the first base-class which is already registered or null.
|
||||
*/
|
||||
@@ -9915,10 +9915,12 @@ void pyrna_alloc_types()
|
||||
|
||||
void BPY_free_srna_pytype(StructRNA *srna)
|
||||
{
|
||||
void *py_ptr = RNA_struct_py_type_get(srna);
|
||||
PyObject *py_ptr = static_cast<PyObject *>(RNA_struct_py_type_get(srna));
|
||||
|
||||
if (py_ptr) {
|
||||
bpy_class_free(py_ptr);
|
||||
/* Remove a reference because `srna` owns it. */
|
||||
bool decref = true;
|
||||
bpy_class_free_ex(py_ptr, decref);
|
||||
RNA_struct_py_type_set(srna, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user