[Bf-blender-cvs] [a91886e76eb] blender2.8: Fix possible key collision w/ BKE_id_to_unique_string_key
Campbell Barton
noreply at git.blender.org
Wed Dec 19 23:36:11 CET 2018
Commit: a91886e76ebd16afe07564713f73c340c940125e
Author: Campbell Barton
Date: Thu Dec 20 09:31:56 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBa91886e76ebd16afe07564713f73c340c940125e
Fix possible key collision w/ BKE_id_to_unique_string_key
BKE_id_full_name_get doesn't ensure unique output, use a simple
method to create a unique key, guaranteed not to collide.
===================================================================
M source/blender/blenkernel/intern/library.c
===================================================================
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 4ddfb0d55f6..070530ca642 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -2209,12 +2209,14 @@ void BKE_id_full_name_ui_prefix_get(char name[MAX_ID_FULL_NAME_UI], const ID *id
*/
char *BKE_id_to_unique_string_key(const struct ID *id)
{
- char name[MAX_ID_FULL_NAME + 2];
- name[0] = id->name[0];
- name[1] = id->name[1];
- BKE_id_full_name_get(name + 2, id);
-
- return BLI_strdup(name);
+ if (id->lib == NULL) {
+ return BLI_strdup(id->name);
+ }
+ else {
+ /* Important library comes first since we can't ensure an object name won't include a library
+ * like identifier at the end, but we _can_ ensure every library has an ID after it. */
+ return BLI_string_joinN(id->lib->id.name, id->name);
+ }
}
void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
More information about the Bf-blender-cvs
mailing list