Fix T90417: font loading creates duplicate ID names

Also repair any errors in existing files.

Error from e0dd3fe587.
This commit is contained in:
Campbell Barton 2021-08-04 12:57:20 +10:00 committed by Jeroen Bakker
parent a609e9f07f
commit 607e3d3b88
Notes: blender-bot 2023-02-14 11:42:40 +01:00
Referenced by issue #90417, font loading creates duplicate ID names
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
3 changed files with 8 additions and 7 deletions

View File

@ -36,7 +36,7 @@
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 20
#define BLENDER_FILE_SUBVERSION 21
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file

View File

@ -293,13 +293,9 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
vfd = BLI_vfontdata_from_freetypefont(pf);
if (vfd) {
vfont = BKE_libblock_alloc(bmain, ID_VF, filename, 0);
/* If there's a font name, use it for the ID name. */
vfont = BKE_libblock_alloc(bmain, ID_VF, vfd->name[0] ? vfd->name : filename, 0);
vfont->data = vfd;
/* if there's a font name, use it for the ID name */
if (vfd->name[0] != '\0') {
BLI_strncpy(vfont->id.name + 2, vfd->name, sizeof(vfont->id.name) - 2);
}
BLI_strncpy(vfont->name, filepath, sizeof(vfont->name));
/* if autopack is on store the packedfile in de font structure */

View File

@ -5087,6 +5087,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 283, 21)) {
ListBase *lb = which_libbase(bmain, ID_VF);
BKE_main_id_repair_duplicate_names_listbase(lb);
}
/**
* Versioning code until next subversion bump goes here.
*