From 735093dee8400ea67bd46ce5a0e93ec80cc44745 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 22 Jan 2021 17:35:47 +0100 Subject: [PATCH] Fix crashes from recent refactor rB131a758b6f88. Much better to add a relation entry for all IDs, even if they are not connected to any other ID. --- source/blender/blenkernel/intern/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index e55b05ce797..4a7636926e6 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -280,6 +280,17 @@ void BKE_main_relations_create(Main *bmain, const short flag) FOREACH_MAIN_ID_BEGIN (bmain, id) { const int idwalk_flag = IDWALK_READONLY | ((flag & MAINIDRELATIONS_INCLUDE_UI) != 0 ? IDWALK_INCLUDE_UI : 0); + + /* Ensure all IDs do have an entry, even if they are not connected to any other. */ + MainIDRelationsEntry **entry_p; + if (!BLI_ghash_ensure_p(bmain->relations->relations_from_pointers, id, (void ***)&entry_p)) { + *entry_p = MEM_callocN(sizeof(**entry_p), __func__); + (*entry_p)->session_uuid = id->session_uuid; + } + else { + BLI_assert((*entry_p)->session_uuid == id->session_uuid); + } + BKE_library_foreach_ID_link( NULL, id, main_relations_create_idlink_cb, bmain->relations, idwalk_flag); }