From 75ac92ed85e6b04678ecae0029941efca4a52fa9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Jun 2023 11:45:45 +1000 Subject: [PATCH 1/3] Fix #109061: UI list generic template fails with error --- scripts/templates_py/ui_list_generic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/templates_py/ui_list_generic.py b/scripts/templates_py/ui_list_generic.py index d33075ddd65..1827cae53d6 100644 --- a/scripts/templates_py/ui_list_generic.py +++ b/scripts/templates_py/ui_list_generic.py @@ -18,8 +18,8 @@ class MyPanel(bpy.types.Panel): draw_ui_list( layout, context, - list_context_path="scene.my_list", - active_index_context_path="scene.my_list_active_index" + list_path="scene.my_list", + active_index_path="scene.my_list_active_index", ) From 1d4ce828e5dbf2379930e979e81b63870d724208 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Jun 2023 11:48:41 +1000 Subject: [PATCH 2/3] PyAPI: require a unique_id for bl_ui.generic_ui_list An empty unique_id would generate a warning when drawing. --- scripts/startup/bl_ui/generic_ui_list.py | 4 ++-- scripts/templates_py/ui_list_generic.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/generic_ui_list.py b/scripts/startup/bl_ui/generic_ui_list.py index 8e58983d38e..d249c55016f 100644 --- a/scripts/startup/bl_ui/generic_ui_list.py +++ b/scripts/startup/bl_ui/generic_ui_list.py @@ -29,7 +29,7 @@ def draw_ui_list( context, class_name="UI_UL_list", *, - unique_id="", + unique_id, list_path, active_index_path, insertion_operators=True, @@ -46,7 +46,7 @@ def draw_ui_list( :type context: :class:`Context` :arg class_name: Name of the UIList class to draw. The default is the UIList class that ships with Blender. :type class_name: str - :arg unique_id: Optional identifier, in case wanting to draw multiple unique copies of a list. + :arg unique_id: Unique identifier to differentiate this from other UI lists. :type unique_id: str :arg list_path: Data path of the list relative to context, eg. "object.vertex_groups". :type list_path: str diff --git a/scripts/templates_py/ui_list_generic.py b/scripts/templates_py/ui_list_generic.py index 1827cae53d6..4113a99d681 100644 --- a/scripts/templates_py/ui_list_generic.py +++ b/scripts/templates_py/ui_list_generic.py @@ -20,6 +20,7 @@ class MyPanel(bpy.types.Panel): context, list_path="scene.my_list", active_index_path="scene.my_list_active_index", + unique_id="my_list_id", ) From a474fdece502b306b277286d2ad9fcbcef3fa79a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Jun 2023 12:06:51 +1000 Subject: [PATCH 3/3] Fix every call to Mesh.shade_flat(..) adding a new layer Also avoid exception handling for checking if the layer exists. --- scripts/modules/bpy_types.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/scripts/modules/bpy_types.py b/scripts/modules/bpy_types.py index 9fb0e390b56..168ab5626db 100644 --- a/scripts/modules/bpy_types.py +++ b/scripts/modules/bpy_types.py @@ -613,8 +613,19 @@ class Mesh(bpy_types.ID): Render and display faces uniform, using face normals, setting the "sharp_face" attribute true for every face """ - sharp_faces = self.attributes.new("sharp_face", 'BOOLEAN', 'FACE') - for value in sharp_faces.data: + attr = self.attributes.get("sharp_face") + if attr is None: + pass + elif attr.data_type == 'BOOLEAN' and attr.domain == 'FACE': + pass + else: + self.attributes.remove(attr) + attr = None + + if attr is None: + attr = self.attributes.new("sharp_face", 'BOOLEAN', 'FACE') + + for value in attr.data: value.value = True def shade_smooth(self): @@ -622,11 +633,9 @@ class Mesh(bpy_types.ID): Render and display faces smooth, using interpolated vertex normals, removing the "sharp_face" attribute """ - try: - attribute = self.attributes["sharp_face"] - self.attributes.remove(attribute) - except KeyError: - pass + attr = self.attributes.get("sharp_face") + if attr is not None: + self.attributes.remove(attr) class MeshEdge(StructRNA):