diff options
-rw-r--r-- | source/blender/blenkernel/BKE_main.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/main.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 516148728d2..b7c70168a49 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -173,6 +173,7 @@ void BKE_main_unlock(struct Main *bmain); void BKE_main_relations_create(struct Main *bmain, const short flag); void BKE_main_relations_free(struct Main *bmain); +void BKE_main_relations_ID_remove(struct Main *bmain, struct ID *id); struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset); 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, |