[Bf-extensions-cvs] [cef282cc] master: Fix T83360: Tree gen error showing "Leaf Object" enum

Campbell Barton noreply at git.blender.org
Thu Jan 7 03:55:19 CET 2021


Commit: cef282cc9acdc1eb4e77d92fa7631f47a47a867c
Author: Campbell Barton
Date:   Thu Jan 7 13:52:09 2021 +1100
Branches: master
https://developer.blender.org/rBAcef282cc9acdc1eb4e77d92fa7631f47a47a867c

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.

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

M	add_curve_sapling/__init__.py

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

diff --git a/add_curve_sapling/__init__.py b/add_curve_sapling/__init__.py
index 9bcd1492..6756797b 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



More information about the Bf-extensions-cvs mailing list