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>2010-11-01 10:19:41 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-11-01 10:19:41 +0300
commitdaa4feaaeae4312eb23f66b948b668a7e9dc1959 (patch)
treedabd2bedd213f9fdfbfc31e6710b2913707dfa1f /source/blender/blenkernel/intern/nla.c
parent8bbcef4c7a377045f6b93580efda93eb4adf800d (diff)
bugfix [#24477] Can easily create bones with duplicate names
- fixed this error 7 different functions (deform groups, uv layers & similar). - support for numbers over 999. - renamed splitIDname() to BLI_split_name_num(), moved to BLI_path_utils
Diffstat (limited to 'source/blender/blenkernel/intern/nla.c')
-rw-r--r--source/blender/blenkernel/intern/nla.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 67c3e746a63..6c8eb69703f 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -1260,27 +1260,21 @@ void BKE_nlastrip_validate_name (AnimData *adt, NlaStrip *strip)
* - in an extreme case, it might not be able to find a name, but then everything else in Blender would fail too :)
*/
if (BLI_ghash_haskey(gh, strip->name)) {
- char tempname[128];
- int number = 1;
- char *dot;
-
- /* Strip off the suffix */
- dot = strrchr(strip->name, '.');
- if (dot) *dot=0;
-
- /* Try different possibilities */
- for (number = 1; number <= 999; number++) {
- /* assemble alternative name */
- BLI_snprintf(tempname, 128, "%s.%03d", strip->name, number);
-
- /* if hash doesn't have this, set it */
- if (BLI_ghash_haskey(gh, tempname) == 0) {
- BLI_strncpy(strip->name, tempname, sizeof(strip->name));
- break;
+ /* note: this block is used in other places, when changing logic apply to all others, search this message */
+ char tempname[sizeof(strip->name)];
+ char left[sizeof(strip->name)];
+ int number;
+ int len= BLI_split_name_num(left, &number, strip->name);
+ do { /* nested while loop looks bad but likely it wont run most times */
+ while(BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", left, number) >= sizeof(tempname)) {
+ if(len > 0) left[--len]= '\0'; /* word too long */
+ else number= 0; /* reset, must be a massive number */
}
- }
- }
+ } while(number++, BLI_ghash_haskey(gh, tempname));
+ BLI_strncpy(strip->name, tempname, sizeof(strip->name));
+ }
+
/* free the hash... */
BLI_ghash_free(gh, NULL, NULL);
}