Commit: 3b39186afa65ff14a5f6b7c79fa9c885729f7bf0 Author: Hans Goudey Date: Mon Jul 12 21:49:21 2021 -0400 Branches: refactor-idprop-ui-data https://developer.blender.org/rB3b39186afa65ff14a5f6b7c79fa9c885729f7bf0
Rename id_properties_create to id_properties_ensure =================================================================== M release/scripts/modules/rna_prop_ui.py M release/scripts/startup/bl_operators/wm.py M source/blender/python/intern/bpy_rna.c M tests/python/bl_pyapi_idprop.py =================================================================== diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index dcfc2425a62..efbaa80a89a 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -42,7 +42,7 @@ def rna_idprop_ui_prop_update(item, prop): def rna_idprop_ui_prop_clear(item, prop): - props = item.id_properties_create() + props = item.id_properties_ensure() props.ui_data_clear(prop) @@ -115,7 +115,7 @@ def rna_idprop_ui_create( rna_idprop_ui_prop_update(item, prop) # Update the UI settings - props = item.id_properties_create() + props = item.id_properties_ensure() props.ui_data_update( prop, subtype=subtype, diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 52f4f355990..acff62015e3 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1429,7 +1429,7 @@ class WM_OT_properties_edit(Operator): prop_type_new = type(prop_value) prop_type, is_array = rna_idprop_value_item_type(prop_value) - props = item.id_properties_create() + props = item.id_properties_ensure() props.ui_data_update( prop, subtype=self.subtype, @@ -1537,7 +1537,7 @@ class WM_OT_properties_edit(Operator): self.default = "" # setup defaults - props = item.id_properties_create() + props = item.id_properties_ensure() rna_data = props.ui_data(prop) self.subtype = rna_data["subtype"] if prop_type in {int, float}: diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 9c3766b66ee..69803963833 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4253,11 +4253,11 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self) return ret; } -PyDoc_STRVAR(pyrna_struct_id_properties_create_doc, - ".. method:: id_properties_create()\n" +PyDoc_STRVAR(pyrna_struct_id_properties_ensure_doc, + ".. method:: id_properties_ensure()\n" " :return: the parent group for an RNA struct's custom IDProperties.\n" " :rtype: :class:`bpy.types.IDPropertyGroup`\n"); -static PyObject *pyrna_struct_id_properties_create(BPy_StructRNA *self) +static PyObject *pyrna_struct_id_properties_ensure(BPy_StructRNA *self) { PYRNA_STRUCT_CHECK_OBJ(self); @@ -5764,10 +5764,10 @@ static struct PyMethodDef pyrna_struct_methods[] = { METH_VARARGS | METH_CLASS, pyrna_struct_bl_rna_get_subclass_doc}, {"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL}, - {"id_properties_create", - (PyCFunction)pyrna_struct_id_properties_create, + {"id_properties_ensure", + (PyCFunction)pyrna_struct_id_properties_ensure, METH_NOARGS, - pyrna_struct_id_properties_create_doc}, + pyrna_struct_id_properties_ensure_doc}, /* experimental */ /* unused for now */ diff --git a/tests/python/bl_pyapi_idprop.py b/tests/python/bl_pyapi_idprop.py index 5cf25b5fb95..18bd5fe968e 100644 --- a/tests/python/bl_pyapi_idprop.py +++ b/tests/python/bl_pyapi_idprop.py @@ -251,7 +251,7 @@ class TestRNAData(TestHelper, unittest.TestCase): def test_custom_properties_none(self): bpy.data.objects.new("test", None) test_object = bpy.data.objects["test"] - props = test_object.id_properties_create() + props = test_object.id_properties_ensure() self.assertEqual(len(props), 0) # Access default RNA data values @@ -282,7 +282,7 @@ class TestRNAData(TestHelper, unittest.TestCase): bpy.data.objects.new("test_2", None) test_object_2 = bpy.data.objects["test_2"] test_object_2["test_prop_3"] = 20.1 - props_2 = test_object_2.id_properties_create() + props_2 = test_object_2.id_properties_ensure() props_2.ui_data_copy(props, "test_prop", "test_prop_3") rna_data = props_2.ui_data("test_prop_3") self.assertEqual(rna_data["min"], 0) @@ -292,14 +292,14 @@ class TestRNAData(TestHelper, unittest.TestCase): # Test RNA data for string property test_object["test_string_prop"] = "Hello there!" - props = test_object.id_properties_create() + props = test_object.id_properties_ensure() props.ui_data_update("test_string_prop", default="Goodbye where?") rna_data = props.ui_data("test_string_prop") self.assertEqual(rna_data["default"], "Goodbye where?") # Test RNA data for array property test_object["test_array_prop"] = [1, 2, 3] - props = test_object.id_properties_create() + props = test_object.id_properties_ensure() props.ui_data_update("test_array_prop", default=[1, 2]) rna_data = props.ui_data("test_array_prop") self.assertEqual(rna_data["default"], [1, 2]) _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs