Browse Source

Fix TemporaryCollectionItem reference bug

pull/437/head
Jrius 2 weeks ago
parent
commit
23af1211cd
  1. 6
      korman/helpers.py

6
korman/helpers.py

@ -62,11 +62,13 @@ class GoodNeighbor:
@contextmanager
def TemporaryCollectionItem(collection):
item = collection.add()
# Blender may recreate the `item` instance as the collection grows and shrink...
# Assign it a unique name so we know which item to delete later on.
name = item.name = str(uuid4())
try:
yield item
finally:
index = next((i for i, j in enumerate(collection) if j == item), None)
if index is not None:
index = collection.find(name)
collection.remove(index)
class TemporaryObject:

Loading…
Cancel
Save