Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-12-20 01:31:56 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-12-20 01:35:46 +0300
commita91886e76ebd16afe07564713f73c340c940125e (patch)
tree9a1265a6c488660086ae015627990973aedb721c /source/blender/blenkernel/intern/library.c
parentc4ee77cde8b0526412da0a626d16877205d3244c (diff)
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.
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r--source/blender/blenkernel/intern/library.c14
1 files changed, 8 insertions, 6 deletions
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)