Fix T99816: renaming attribute works incorrectly

This fixes two issues:
* There was a crash when the new attribute name was empty.
* The attribute name was incremented (e.g. "Attribute.001") when
  the old and new name were the same.
This commit is contained in:
Jacques Lucke 2022-07-25 13:16:59 +02:00
parent 332d547ab7
commit d567785658
Notes: blender-bot 2023-02-14 01:07:44 +01:00
Referenced by issue #99816, Renaming Atrribute in the data panel does not accont for using the original name or a blank space.
1 changed files with 7 additions and 0 deletions

View File

@ -146,6 +146,13 @@ bool BKE_id_attribute_rename(ID *id,
BLI_assert_msg(0, "Required attribute name is not editable");
return false;
}
if (STREQ(new_name, "")) {
BKE_report(reports, RPT_ERROR, "Attribute name can not be empty");
return false;
}
if (STREQ(old_name, new_name)) {
return false;
}
CustomDataLayer *layer = BKE_id_attribute_search(
id, old_name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);