diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-10-13 16:49:54 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-10-13 16:53:09 +0300 |
commit | 356dce13f05faed5303ac1aacf68dc6c1ff51d80 (patch) | |
tree | ce7c532f4a06d7482627f9a670a374bae4841665 /source/blender/depsgraph/intern/eval | |
parent | c29f20a52151b90734edb7b4ebbd9b7b49e65d73 (diff) |
Fix T92136: Leak accessing evaluated depsgraph data from Python
Copy-on-write data blocks could be referenced from python but were not
properly managing python reference counting.
This would leak memory for any evaluated data-blocks accessed by Python.
Reviewed By: sergey
Ref D12850
Diffstat (limited to 'source/blender/depsgraph/intern/eval')
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc | 2 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index b4a91944b65..68a72638c7d 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -822,6 +822,7 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph, const IDNode /* Sanity checks. */ BLI_assert(check_datablock_expanded(id_cow) == false); + BLI_assert(id_cow->py_instance == nullptr); /* Copy data from original ID to a copied version. */ /* TODO(sergey): Avoid doing full ID copy somehow, make Mesh to reference @@ -1015,6 +1016,7 @@ void deg_free_copy_on_write_datablock(ID *id_cow) break; } discard_edit_mode_pointers(id_cow); + BKE_libblock_free_data_py(id_cow); BKE_libblock_free_datablock(id_cow, 0); BKE_libblock_free_data(id_cow, false); /* Signal datablock as not being expanded. */ diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc index 7893e8c64c1..8bf64af7d5d 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc @@ -52,7 +52,9 @@ void RuntimeBackup::init_from_id(ID *id) } have_backup = true; + /* Clear, so freeing the expanded data doesn't touch this Python reference. */ id_data.py_instance = id->py_instance; + id->py_instance = nullptr; animation_backup.init_from_id(id); |