Commit: 0d8a8ce03b995142a9c3c183028d1c69d453a93f Author: Bastien Montagne Date: Thu Feb 20 11:28:23 2020 +0100 Branches: master https://developer.blender.org/rB0d8a8ce03b995142a9c3c183028d1c69d453a93f
Fix some issues with versionning of older files. Consequences of own refactor of usercount handling in readfile.c (rB367ecff15d74). Not super happy to have to call that function twice, but that should be OK (not a real overhead here anyway). =================================================================== M source/blender/blenloader/intern/readfile.c =================================================================== 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); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs