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:
authorEthan-Hall <Ethan1080>2022-08-04 01:16:46 +0300
committerJoseph Eagar <joeedh@gmail.com>2022-08-04 01:16:46 +0300
commit177bc807480e85b6dd331a48af379cb795719151 (patch)
tree64106ce36186324ded6d7c1470a1e44bc345ba34
parentb65ab293105d3dfceee8f3bafa3936cfebad8200 (diff)
Fix: add attribute with empty string name crash
Due to a recent change, empty strings are unhandled. This results in Blender crashing. This patch fixes the crash but a discrepancy still exists... Prior to the regression, the empty string would be replaced by the name of the data type. This patch uses "Attribute" for the default name regardless of type. Restoring the previous behavior would require making and/or modifying API methods. Regression introduced in: rBeae36be372a6 Reviewed By: Joseph Eagar & Campbell Barton Differential Revision: https://developer.blender.org/D14734 Ref D14734
-rw-r--r--source/blender/blenkernel/intern/attribute.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc
index 639e190a2c6..b6d39486313 100644
--- a/source/blender/blenkernel/intern/attribute.cc
+++ b/source/blender/blenkernel/intern/attribute.cc
@@ -20,9 +20,12 @@
#include "DNA_pointcloud_types.h"
#include "BLI_index_range.hh"
+#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_string_utils.h"
+#include "BLT_translation.h"
+
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_curves.hh"
@@ -201,7 +204,14 @@ bool BKE_id_attribute_calc_unique_name(ID *id, const char *name, char *outname)
{
AttrUniqueData data{id};
- BLI_strncpy_utf8(outname, name, MAX_CUSTOMDATA_LAYER_NAME);
+ /* Set default name if none specified.
+ * NOTE: We only call IFACE_() if needed to avoid locale lookup overhead. */
+ if (!name || name[0] == '\0') {
+ BLI_strncpy(outname, IFACE_("Attribute"), MAX_CUSTOMDATA_LAYER_NAME);
+ }
+ else {
+ BLI_strncpy_utf8(outname, name, MAX_CUSTOMDATA_LAYER_NAME);
+ }
return BLI_uniquename_cb(
unique_name_cb, &data, nullptr, '.', outname, MAX_CUSTOMDATA_LAYER_NAME);