mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Bonsai: tolerate an already-removed mesh/curve/camera data-block in delete_data (#5793)
tool.Geometry.delete_data() only guarded against TypeError (passing the wrong bpy.data collection). If the data-block had already been freed elsewhere between the earlier has_data_users() check and this deferred cleanup call (observed after a busy sequence of switch_representation calls followed by remove_representation), bpy.data.meshes.remove() raises an uncaught ReferenceError, which aborts the whole IFC operator transaction with a traceback matching the one reported in #5793. Catch ReferenceError too and treat an already-removed data-block as a no-op, since the desired end state (the data being gone) is already met. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -373,6 +373,12 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
bpy.data.curves.remove(data)
|
||||
except TypeError:
|
||||
bpy.data.cameras.remove(data)
|
||||
except ReferenceError:
|
||||
# The data-block was already removed elsewhere (e.g. purged as an
|
||||
# orphan in between an earlier "has data users" check and this
|
||||
# deferred cleanup call). It's already gone, so there's nothing
|
||||
# left to do.
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def is_locked(cls, element: ifcopenshell.entity_instance) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user