diff options
author | Yuki Hashimoto <hzuika> | 2022-03-29 16:27:15 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-03-29 16:29:15 +0300 |
commit | 9ec77d709c3cd8cc6b210fd4c5fbf762bd18188e (patch) | |
tree | b53c5b647bd386d2aef4915f3d4dc7d2a8631071 | |
parent | 4a5cd4e6c75d2a41ba0bffd971cd768ee76077ae (diff) |
Fix T63795: Display custom properties with brackets in info
When custom properties are changed, they are displayed with brackets in
info.
Ref D14380
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 20 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 15 |
2 files changed, 31 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index b4617321f44..67fa29adb47 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -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; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b45c638d7b9..a3d2d38136c 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -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 { |