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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-11-24 21:21:35 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-11-24 22:04:53 +0300
commitfa0fcbe4d6ca3f183f02395fe9ba18fb5ea87748 (patch)
tree4cd30bcace27e7b558d417cf99f4dcb38f81440e /source/blender/blenkernel/intern/customdata.c
parent5166132708a42ce57ac83a6e5f85fe4190dba312 (diff)
Fix T56374, T57066, T58037: crash on startup on macOS when using translation.
Diffstat (limited to 'source/blender/blenkernel/intern/customdata.c')
-rw-r--r--source/blender/blenkernel/intern/customdata.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index a0fa08708b1..e841832f51c 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1874,7 +1874,14 @@ static CustomDataLayer *customData_add_layer__internal(
data->layers[index].flag = flag;
data->layers[index].data = newlayerdata;
- if (name || (name = DATA_(typeInfo->defaultname))) {
+ /* Set default name if none exists. Note we only call DATA_() once
+ * we know there is a default name, to avoid overhead of locale lookups
+ * in the depsgraph. */
+ if (!name && typeInfo->defaultname) {
+ name = DATA_(typeInfo->defaultname);
+ }
+
+ if (name) {
BLI_strncpy(data->layers[index].name, name, sizeof(data->layers[index].name));
CustomData_set_layer_unique_name(data, index);
}
@@ -3440,11 +3447,17 @@ void CustomData_set_layer_unique_name(CustomData *data, int index)
data_arg.type = nlayer->type;
data_arg.index = index;
- if (!typeInfo->defaultname)
+ if (!typeInfo->defaultname) {
return;
+ }
+
+ /* Set default name if none specified. Note we only call DATA_() when
+ * needed to avoid overhead of locale lookups in the depsgraph. */
+ if (nlayer->name[0] == '\0') {
+ STRNCPY(nlayer->name, DATA_(typeInfo->defaultname));
+ }
- BLI_uniquename_cb(customdata_unique_check, &data_arg, DATA_(typeInfo->defaultname), '.', nlayer->name,
- sizeof(nlayer->name));
+ BLI_uniquename_cb(customdata_unique_check, &data_arg, NULL, '.', nlayer->name, sizeof(nlayer->name));
}
void CustomData_validate_layer_name(const CustomData *data, int type, const char *name, char *outname)