mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 14:26:30 +00:00
Evict stale snap_objs cache entries on ReferenceError
When a Blender object is deleted while the snap cache still holds a SnapObj referencing it, accessing snap_obj.obj.name raises ReferenceError. Catch it, evict the dead entry, and let the caller retry cleanly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -970,7 +970,12 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
if obj.data is None or not isinstance(obj.data, bpy.types.Mesh):
|
if obj.data is None or not isinstance(obj.data, bpy.types.Mesh):
|
||||||
return None
|
return None
|
||||||
for i, snap_obj in enumerate(cls.snap_objs):
|
for i, snap_obj in enumerate(cls.snap_objs):
|
||||||
if obj.name == snap_obj.obj.name:
|
try:
|
||||||
|
cached_name = snap_obj.obj.name
|
||||||
|
except ReferenceError:
|
||||||
|
cls.snap_objs.pop(i)
|
||||||
|
break
|
||||||
|
if obj.name == cached_name:
|
||||||
# Fast O(1) invalidation: vertex count change (mesh edit) or
|
# Fast O(1) invalidation: vertex count change (mesh edit) or
|
||||||
# world matrix change (object moved/rotated).
|
# world matrix change (object moved/rotated).
|
||||||
if len(obj.data.vertices) != len(snap_obj.verts_3d):
|
if len(obj.data.vertices) != len(snap_obj.verts_3d):
|
||||||
|
|||||||
Reference in New Issue
Block a user