diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-10-12 09:52:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-10-12 09:55:02 +0300 |
commit | fe958d7d993e849527839486ef37c6239e3c5f5c (patch) | |
tree | f327fb79a4e0545c2a8c9d03f2951a5e9eee8de2 /source/blender/python/intern | |
parent | c1c6c11ca6c5f4cd775b787910fe69119b054af2 (diff) |
Fix leak on exit when WITH_PYTHON_SAFETY is enabled
The lead only occurred when Python references were leaking as well.
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 92499d3c0ff..8c83f611b5c 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -180,6 +180,15 @@ static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref); static PyMethodDef id_free_weakref_cb_def = { "id_free_weakref_cb", (PyCFunction)id_free_weakref_cb, METH_O, NULL}; +/** + * Only used when there are values left on exit (causing memory leaks). + */ +static void id_weakref_pool_free_value_fn(void *p) +{ + GHash *weakinfo_hash = p; + BLI_ghash_free(weakinfo_hash, NULL, NULL); +} + /* Adds a reference to the list, remember to decref. */ static GHash *id_weakref_pool_get(ID *id) { @@ -7633,7 +7642,7 @@ void BPY_rna_exit(void) printf("ID: %s\n", id->name); } } - BLI_ghash_free(id_weakref_pool, NULL, NULL); + BLI_ghash_free(id_weakref_pool, NULL, id_weakref_pool_free_value_fn); id_weakref_pool = NULL; #endif } |