From dd6dcf824793f62b70611cf588f52ab372697dbf Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 7 Feb 2019 21:52:54 +0100 Subject: Cleanup: Use new BKE_main_foreach_id() in a few more places... --- source/blender/blenkernel/intern/main.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern/main.c') diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index 2d3988ed8f5..d5b9147b34f 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -140,7 +140,7 @@ void BKE_main_unlock(struct Main *bmain) } -static int main_relations_create_cb(void *user_data, ID *id_self, ID **id_pointer, int cb_flag) +static int main_relations_create_idlink_cb(void *user_data, ID *id_self, ID **id_pointer, int cb_flag) { MainIDRelations *rel = user_data; @@ -173,13 +173,15 @@ static int main_relations_create_cb(void *user_data, ID *id_self, ID **id_pointe return IDWALK_RET_NOP; } +static bool main_relations_create_id_cb(Main *bmain, ID *id, void *UNUSED(user_data)) +{ + BKE_library_foreach_ID_link(NULL, id, main_relations_create_idlink_cb, bmain->relations, IDWALK_READONLY); + return true; +} + /** Generate the mappings between used IDs and their users, and vice-versa. */ void BKE_main_relations_create(Main *bmain) { - ListBase *lbarray[MAX_LIBARRAY]; - ID *id; - int a; - if (bmain->relations != NULL) { BKE_main_relations_free(bmain); } @@ -189,11 +191,7 @@ void BKE_main_relations_create(Main *bmain) bmain->relations->id_user_to_used = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); bmain->relations->entry_pool = BLI_mempool_create(sizeof(MainIDRelationsEntry), 128, 128, BLI_MEMPOOL_NOP); - for (a = set_listbasepointers(bmain, lbarray); a--; ) { - for (id = lbarray[a]->first; id; id = id->next) { - BKE_library_foreach_ID_link(NULL, id, main_relations_create_cb, bmain->relations, IDWALK_READONLY); - } - } + BKE_main_foreach_id(bmain, false, main_relations_create_id_cb, NULL); } void BKE_main_relations_free(Main *bmain) @@ -237,6 +235,7 @@ bool BKE_main_listbase_foreach_id( * \param reverse_type_order Allow to reverse order in which ID *types* are handled * (i.e. does not reverse the order in which IDs themselves are handled * whithin a give listbase). + * Note that in most cases, you want to set that parameter to true. * \return false if the iteration was iterrupted by the callback. * * \warning \a callback may affect the ID, but DO NOT change the Main database (add/remove/reorder its IDs). -- cgit v1.2.3