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
This commit is contained in:
parent
c29f20a521
commit
356dce13f0
Notes:
blender-bot
2023-02-14 09:43:37 +01:00
Referenced by issue #92136, Accessing evaluated depsgraph data from Python leaks memory
|
@ -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. */
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue