Fix T63795: Display custom properties with brackets in info

When custom properties are changed, they are displayed with brackets in
info.

Ref D14380
This commit is contained in:
Yuki Hashimoto 2022-03-30 00:27:15 +11:00 committed by Campbell Barton
parent 4a5cd4e6c7
commit 9ec77d709c
Notes: blender-bot 2023-02-14 11:21:40 +01:00
Referenced by issue #63795, data path for custom prop  is wrong for info menu
2 changed files with 31 additions and 4 deletions

View File

@ -6012,13 +6012,29 @@ char *RNA_path_struct_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
char *RNA_path_property_py(const PointerRNA *UNUSED(ptr), PropertyRNA *prop, int index)
{
const bool is_rna = (prop->magic == RNA_MAGIC);
const char *propname = RNA_property_identifier(prop);
char *ret;
if ((index == -1) || (RNA_property_array_check(prop) == false)) {
ret = BLI_sprintfN("%s", RNA_property_identifier(prop));
if (is_rna) {
ret = BLI_strdup(propname);
}
else {
char propname_esc[MAX_IDPROP_NAME * 2];
BLI_str_escape(propname_esc, propname, sizeof(propname_esc));
ret = BLI_sprintfN("[\"%s\"]", propname_esc);
}
}
else {
ret = BLI_sprintfN("%s[%d]", RNA_property_identifier(prop), index);
if (is_rna) {
ret = BLI_sprintfN("%s[%d]", propname, index);
}
else {
char propname_esc[MAX_IDPROP_NAME * 2];
BLI_str_escape(propname_esc, propname, sizeof(propname_esc));
ret = BLI_sprintfN("[\"%s\"][%d]", propname_esc, index);
}
}
return ret;

View File

@ -588,7 +588,13 @@ char *WM_context_path_resolve_property_full(const bContext *C,
if (data_path != NULL) {
if (prop != NULL) {
char *prop_str = RNA_path_property_py(ptr, prop, index);
member_id_data_path = BLI_string_join_by_sep_charN('.', member_id, data_path, prop_str);
if (prop_str[0] == '[') {
member_id_data_path = BLI_string_joinN(member_id, ".", data_path, prop_str);
}
else {
member_id_data_path = BLI_string_join_by_sep_charN(
'.', member_id, data_path, prop_str);
}
MEM_freeN(prop_str);
}
else {
@ -600,7 +606,12 @@ char *WM_context_path_resolve_property_full(const bContext *C,
else {
if (prop != NULL) {
char *prop_str = RNA_path_property_py(ptr, prop, index);
member_id_data_path = BLI_string_join_by_sep_charN('.', member_id, prop_str);
if (prop_str[0] == '[') {
member_id_data_path = BLI_string_joinN(member_id, prop_str);
}
else {
member_id_data_path = BLI_string_join_by_sep_charN('.', member_id, prop_str);
}
MEM_freeN(prop_str);
}
else {