[Bf-blender-cvs] [9ec77d709c3] master: Fix T63795: Display custom properties with brackets in info

Yuki Hashimoto noreply at git.blender.org
Tue Mar 29 15:31:10 CEST 2022


Commit: 9ec77d709c3cd8cc6b210fd4c5fbf762bd18188e
Author: Yuki Hashimoto
Date:   Wed Mar 30 00:27:15 2022 +1100
Branches: master
https://developer.blender.org/rB9ec77d709c3cd8cc6b210fd4c5fbf762bd18188e

Fix T63795: Display custom properties with brackets in info

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

Ref D14380

===================================================================

M	source/blender/makesrna/intern/rna_access.c
M	source/blender/windowmanager/intern/wm_operators.c

===================================================================

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 {



More information about the Bf-blender-cvs mailing list