mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
fix 8119: Fix ReferenceError in snap object cache lookup
Cached SnapObj entries holding references to freed Blender objects raised ReferenceError on .obj.name access. Evict stale entries at the start of create_snap_obj. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -888,6 +888,15 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
def create_snap_obj(cls, obj):
|
def create_snap_obj(cls, obj):
|
||||||
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
|
||||||
|
# Evict cached entries whose Blender object has since been freed.
|
||||||
|
valid = []
|
||||||
|
for s in cls.snap_objs:
|
||||||
|
try:
|
||||||
|
_ = s.obj.name
|
||||||
|
valid.append(s)
|
||||||
|
except ReferenceError:
|
||||||
|
pass
|
||||||
|
cls.snap_objs[:] = valid
|
||||||
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:
|
if obj.name == snap_obj.obj.name:
|
||||||
# Handle objects modified while a modal operator is active.
|
# Handle objects modified while a modal operator is active.
|
||||||
|
|||||||
Reference in New Issue
Block a user