[Bf-blender-cvs] [29590eec6e2] master: Fix T91054: List of strings custom property cannot be edited

Hans Goudey noreply at git.blender.org
Tue Aug 31 05:21:21 CEST 2021


Commit: 29590eec6e21a4e1a2d45221e6dbb5733c354969
Author: Hans Goudey
Date:   Mon Aug 30 22:21:11 2021 -0500
Branches: master
https://developer.blender.org/rB29590eec6e21a4e1a2d45221e6dbb5733c354969

Fix T91054: List of strings custom property cannot be edited

This commit fixes editing the value of a list of strings custom property
with the "Custom Property Edit" operator. This sort of custom property
isn't very well supported in general, but editing the values should
work properly anyway.

Differential Revision: https://developer.blender.org/D12348

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

M	release/scripts/startup/bl_operators/wm.py

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

diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 989c067efec..f975176a1e2 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -1429,10 +1429,8 @@ class WM_OT_properties_edit(Operator):
         prop_type_new = type(prop_value)
         prop_type, is_array = rna_idprop_value_item_type(prop_value)
 
-        ui_data = item.id_properties_ui(prop)
-        ui_data.update(subtype=self.subtype, description=self.description)
-
         if prop_type == int:
+            ui_data = item.id_properties_ui(prop)
             if type(default_eval) == str:
                 self.report({'WARNING'}, "Could not evaluate number from default value")
                 default_eval = None
@@ -1444,8 +1442,11 @@ class WM_OT_properties_edit(Operator):
                 soft_min=int(round(self.soft_min)),
                 soft_max=int(round(self.soft_max)),
                 default=default_eval,
+                subtype=self.subtype,
+                description=self.description
             )
         elif prop_type == float:
+            ui_data = item.id_properties_ui(prop)
             if type(default_eval) == str:
                 self.report({'WARNING'}, "Could not evaluate number from default value")
                 default_eval = None
@@ -1455,9 +1456,16 @@ class WM_OT_properties_edit(Operator):
                 soft_min=self.soft_min,
                 soft_max=self.soft_max,
                 default=default_eval,
+                subtype=self.subtype,
+                description=self.description
+            )
+        elif prop_type == str and not is_array: # String arrays do not support UI data.
+            ui_data = item.id_properties_ui(prop)
+            ui_data.update(
+                default=self.default,
+                subtype=self.subtype,
+                description=self.description
             )
-        elif prop_type == str:
-            ui_data.update(default=self.default)
 
         # If we have changed the type of the property, update its potential anim curves!
         if prop_type_old != prop_type_new:
@@ -1531,10 +1539,10 @@ class WM_OT_properties_edit(Operator):
             self.default = ""
 
         # setup defaults
-        ui_data = item.id_properties_ui(prop)
-        rna_data = ui_data.as_dict()
-        self.subtype =  rna_data["subtype"]
         if prop_type in {int, float}:
+            ui_data = item.id_properties_ui(prop)
+            rna_data = ui_data.as_dict()
+            self.subtype =  rna_data["subtype"]
             self.min = rna_data["min"]
             self.max = rna_data["max"]
             self.soft_min = rna_data["soft_min"]
@@ -1543,7 +1551,11 @@ class WM_OT_properties_edit(Operator):
                 self.min != self.soft_min or
                 self.max != self.soft_max
             )
-        if prop_type in {int, float, str}:
+            self.default = str(rna_data["default"])
+        if prop_type == str and not is_array: # String arrays do not support UI data.
+            ui_data = item.id_properties_ui(prop)
+            rna_data = ui_data.as_dict()
+            self.subtype =  rna_data["subtype"]
             self.default = str(rna_data["default"])
 
         self._init_subtype(prop_type, is_array, self.subtype)



More information about the Bf-blender-cvs mailing list