From 23af1211cdcf13a597a10fb9e604b331d1d365b7 Mon Sep 17 00:00:00 2001 From: Jrius <2261279+Jrius@users.noreply.github.com> Date: Mon, 24 Feb 2025 18:50:22 +0100 Subject: [PATCH 1/2] Fix TemporaryCollectionItem reference bug --- korman/helpers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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): From c6f2c4d76ec8b2eb0ede321acea7aa68c24a7d3c Mon Sep 17 00:00:00 2001 From: Jrius <2261279+Jrius@users.noreply.github.com> Date: Tue, 25 Feb 2025 19:42:05 +0100 Subject: [PATCH 2/2] Fix import --- korman/helpers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/korman/helpers.py b/korman/helpers.py index eaa1c0c..b3bd4ac 100644 --- a/korman/helpers.py +++ b/korman/helpers.py @@ -18,6 +18,7 @@ import bpy from contextlib import contextmanager import math from typing import * +from uuid import uuid4 @contextmanager def bmesh_from_object(bl):