Merge branch 'blender-v4.5-release'
This commit is contained in:
@@ -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