diff options
author | Bastien Montagne <bastien@blender.org> | 2021-01-22 19:35:47 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-01-22 19:37:09 +0300 |
commit | 735093dee8400ea67bd46ce5a0e93ec80cc44745 (patch) | |
tree | 0e9c50512ac2b3d71e4bab1eb6530c5d08d59e66 /source/blender/blenkernel/intern | |
parent | 3469e06c1a6b84fbf6888f57e8f03653bacce354 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/main.c | 11 |
1 files changed, 11 insertions, 0 deletions
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); } |