diff options
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2536de50900..4adce2d796c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9746,6 +9746,15 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) /* Skip in undo case. */ if (fd->memfile == NULL) { + /* Note that we cannot recompute usercounts at this point in undo case, we play too much with + * IDs from different memory realms, and Main database is not in a fully valid state yet. + */ + /* Some versioning code does expect some proper userrefcounting, e.g. in conversion from + * groups to collections... We could optimize out that first call when we are reading a + * current version file, but again this is really not a bottle neck currently. so not worth + * it. */ + BKE_main_id_refcount_recompute(bfd->main, false); + /* Yep, second splitting... but this is a very cheap operation, so no big deal. */ blo_split_main(&mainlist, bfd->main); for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) { @@ -9754,11 +9763,9 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) } blo_join_main(&mainlist); - /* Note that we cannot recompute usercounts at this point in undo case, we play too much with - * IDs from different memory realms, and Main database is not in a fully valid state yet. - */ - /* Also, this does not take into account old, deprecated data, so we have to do it after - * `do_versions_after_linking()`. */ + /* And we have to compute those userrefcounts again, as `do_versions_after_linking()` does + * not always properly handle user counts, and/or that function does not take into account + * old, deprecated data. */ BKE_main_id_refcount_recompute(bfd->main, false); /* After all data has been read and versioned, uses LIB_TAG_NEW. */ @@ -11454,6 +11461,13 @@ static void library_link_end(Main *mainl, mainl = NULL; /* blo_join_main free's mainl, cant use anymore */ lib_link_all(*fd, mainvar); + + /* Some versioning code does expect some proper userrefcounting, e.g. in conversion from + * groups to collections... We could optimize out that first call when we are reading a + * current version file, but again this is really not a bottle neck currently. so not worth + * it. */ + BKE_main_id_refcount_recompute(mainvar, false); + BKE_collections_after_lib_link(mainvar); /* Yep, second splitting... but this is a very cheap operation, so no big deal. */ @@ -11475,7 +11489,7 @@ static void library_link_end(Main *mainl, mainvar = (*fd)->mainlist->first; MEM_freeN((*fd)->mainlist); - /* This does not take into account old, deprecated data, so we have to do it after + /* This does not take into account old, deprecated data, so we also have to do it after * `do_versions_after_linking()`. */ BKE_main_id_refcount_recompute(mainvar, false); |