Fix (studio-reported) liboverride resync crash after recent changes.

Recent own rBabf3ce811f6e prevented any LayerCollection update during
the whole liboverride resync process, for both performances and feature
reasons.

However that means that the various runtime caches like the Base GHash
are not cleared anymore during ID remapping process, so we need to call
`BKE_main_collection_sync_remap` instead of `BKE_main_collection_sync`
when we finally are ready for this update.

Reported by @eyecandy (Andy Goralczyk) from Blender studio, thanks!
This commit is contained in:
Bastien Montagne 2021-07-28 12:24:07 +02:00
parent 91dd1a1ba3
commit 544ddcdaac
2 changed files with 10 additions and 1 deletions

View File

@ -748,6 +748,11 @@ int BKE_layer_collection_findindex(ViewLayer *view_layer, const LayerCollection
*
* WARNING: This is not threadsafe at all, only use from main thread.
*
* NOTE: It is probably needed to use #BKE_main_collection_sync_remap instead
* of just #BKE_main_collection_sync after disabling LayerCollection resync,
* unless it is absolutely certain that no ID remapping (or any other process
* that may invalidate the caches) will happen while it is disabled.
*
* NOTE: This is a quick and safe band-aid around the long-known issue
* regarding this resync process.
* Proper fix would be to make resync itself lazy, i.e. only happen

View File

@ -772,7 +772,11 @@ static void lib_override_library_create_post_process(Main *bmain,
/* NOTE: We only care about local IDs here, if a linked object is not instantiated in any way we
* do not do anything about it. */
BKE_main_collection_sync(bmain);
/* We need to use the `_remap` version here as we prevented any LayerCollection resync during the
* whole liboverride resyncing, which involves a lot of ID remapping.
*
* Otherwise, cached Base GHash e.g. can contain invalid stale data. */
BKE_main_collection_sync_remap(bmain);
/* We create a set of all objects referenced into the scene by its hierarchy of collections.
* NOTE: This is different that the list of bases, since objects in excluded collections etc.