diff --git a/korman/helpers.py b/korman/helpers.py index 35c0176..eaa1c0c 100644 --- a/korman/helpers.py +++ b/korman/helpers.py @@ -62,12 +62,14 @@ 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: - collection.remove(index) + index = collection.find(name) + collection.remove(index) class TemporaryObject: def __init__(self, obj, remove_func):