Undo to clear listeners for linked objects

Typically it's already covered by rebuild_element_maps after undo but just to be consistent with commit_link_element.
This commit is contained in:
Andrej730
2024-10-23 15:01:27 +05:00
parent fa29c42887
commit 6f347bcb81
+13 -3
View File
@@ -282,17 +282,27 @@ class IfcStore:
Operation(rollback=IfcStore.rollback_link_element, commit=IfcStore.commit_link_element, data=data)
)
@staticmethod
def get_object_by_name(name: str) -> Union[IFC_CONNECTED_TYPE, None]:
obj = bpy.data.objects.get(name)
if not obj:
obj = bpy.data.materials.get(name)
return obj
@staticmethod
def rollback_link_element(data: OperationData) -> None:
del IfcStore.id_map[data["id"]]
if data["guid"]:
del IfcStore.guid_map[data["guid"]]
obj = IfcStore.get_object_by_name(data["obj"])
if obj is None:
# obj was just created during this step and didn't existed before.
return
bpy.msgbus.clear_by_owner(obj)
@staticmethod
def commit_link_element(data: OperationData) -> None:
obj = bpy.data.objects.get(data["obj"])
if not obj:
obj = bpy.data.materials.get(data["obj"])
obj = IfcStore.get_object_by_name(data["obj"])
IfcStore.id_map[data["id"]] = obj
if "guid" in data:
IfcStore.guid_map[data["guid"]] = obj