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
This commit is contained in:
parent
b65ab29310
commit
177bc80748
Notes:
blender-bot
2023-02-14 08:33:26 +01:00
Referenced by issue #100265, Regression? - Old keymaps aren't read properly
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue