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:
authorDalai Felinto <dfelinto@gmail.com>2018-01-19 22:19:55 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-01-19 22:24:35 +0300
commit4dfccf8b7f2dfea787d7155b9c531cf56c1b33ae (patch)
treefafdad5a4ae76938a1e3e39540d92b465acaea04 /source/blender/blenkernel/intern/collection.c
parent244fb3ebe03c4feed752b9ed33afe26b393996c4 (diff)
Collections: Fix for auto-named children when parent name is MAX_NAME
Reported via IRC by Vuk Gardašević (lijenstina).
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r--source/blender/blenkernel/intern/collection.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 6846683fe13..d0f89eb46e5 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -30,6 +30,7 @@
#include "BLI_ghash.h"
#include "BLI_iterator.h"
#include "BLI_listbase.h"
+#include "BLI_math_base.h"
#include "BLT_translation.h"
#include "BLI_string_utils.h"
@@ -86,7 +87,12 @@ SceneCollection *BKE_collection_add(ID *owner_id, SceneCollection *sc_parent, co
name = BLI_sprintfN("Collection %d", BLI_listbase_count(&sc_master->scene_collections) + 1);
}
else {
- name = BLI_sprintfN("%s %d", sc_parent->name, BLI_listbase_count(&sc_parent->scene_collections) + 1);
+ const int number = BLI_listbase_count(&sc_parent->scene_collections) + 1;
+ const int digits = integer_digits_i(number);
+ const int max_len = sizeof(sc_parent->name)
+ - 1 /* NULL terminator */
+ - (1 + digits) /* " %d" */;
+ name = BLI_sprintfN("%.*s %d", max_len, sc_parent->name, number);
}
}