diff options
author | Bastien Montagne <bastien@blender.org> | 2020-06-26 18:50:23 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-06-29 18:28:04 +0300 |
commit | b723d3881266c4cd93e57959b476982d2879c15c (patch) | |
tree | b46656704ebfd054642f375f08954c84dcacadbf /source/blender/blenkernel/intern | |
parent | cff688ce7b5c4a0e0605b365a57cd7fc2ebb797a (diff) |
Add utils to remove an ID from the relations runtime data in Main.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/main.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index ea3bee8b2f6..4b577ccec2c 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -288,6 +288,29 @@ void BKE_main_relations_free(Main *bmain) } /** + * Remove an ID from the relations (the two entries for that ID, not the ID from entries in other + * IDs' relationships). + * + * Does not free any allocated memory. + * Allows to use those relations as a way to mark an ID as already processed, without requiring any + * additional tagging or GSet. + * Obviously, relations should be freed after use then, since this will make them fully invalid. + */ +void BKE_main_relations_ID_remove(Main *bmain, ID *id) +{ + if (bmain->relations) { + /* Note: we do not free the entries from the mempool, those will be dealt with when finally + * freeing the whole relations. */ + if (bmain->relations->id_used_to_user) { + BLI_ghash_remove(bmain->relations->id_used_to_user, id, NULL, NULL); + } + if (bmain->relations->id_user_to_used) { + BLI_ghash_remove(bmain->relations->id_user_to_used, id, NULL, NULL); + } + } +} + +/** * Create a GSet storing all IDs present in given \a bmain, by their pointers. * * \param gset: If not NULL, given GSet will be extended with IDs from given \a bmain, |