From cef282cc9acdc1eb4e77d92fa7631f47a47a867c Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Thu, 7 Jan 2021 13:52:09 +1100 Subject: [PATCH] Fix T83360: Tree gen error showing "Leaf Object" enum Account for limitation in the Python API which needs to keep references to strings used in an enum. --- add_curve_sapling/__init__.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/add_curve_sapling/__init__.py b/add_curve_sapling/__init__.py index 9bcd14923..6756797b5 100644 --- a/add_curve_sapling/__init__.py +++ b/add_curve_sapling/__init__.py @@ -246,16 +246,21 @@ class AddTree(Operator): bl_label = "Sapling: Add Tree" bl_options = {'REGISTER', 'UNDO'} + # Keep the strings in memory, see T83360. + _objectList_static_strings = [] + def objectList(self, context): - objects = [] - bObjects = bpy.data.objects + objects = AddTree._objectList_static_strings + objects.clear() - for obj in bObjects: - if (obj.type in ['MESH', 'CURVE', 'SURFACE']) and (obj.name not in ['tree', 'leaves']): + for obj in bpy.data.objects: + if (obj.type in {'MESH', 'CURVE', 'SURFACE'}) and (obj.name not in {'tree', 'leaves'}): objects.append((obj.name, obj.name, "")) - return (objects if objects else - [('NONE', "No objects", "No appropriate objects in the Scene")]) + if not objects: + objects.append(('NONE', "No objects", "No appropriate objects in the Scene")) + + return objects def update_tree(self, context): self.do_update = True -- GitLab