mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
Fix bug where unlinking operations were not stored in the undo stack
This commit is contained in:
@@ -323,6 +323,21 @@ class IfcStore:
|
|||||||
# TODO Listeners are not re-registered. Does this cause nasty problems to debug later on?
|
# TODO Listeners are not re-registered. Does this cause nasty problems to debug later on?
|
||||||
# TODO We're handling id_map and guid_map, but what about edited_objs? This might cause big problems.
|
# TODO We're handling id_map and guid_map, but what about edited_objs? This might cause big problems.
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def rollback_unlink_element(data):
|
||||||
|
if "id" not in data or "obj" not in data:
|
||||||
|
return
|
||||||
|
obj = bpy.data.objects.get(data["obj"])
|
||||||
|
IfcStore.id_map[data["id"]] = obj
|
||||||
|
if data["guid"]:
|
||||||
|
IfcStore.guid_map[data["guid"]] = obj
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def commit_unlink_element(data):
|
||||||
|
del IfcStore.id_map[data["id"]]
|
||||||
|
if data["guid"]:
|
||||||
|
del IfcStore.guid_map[data["guid"]]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def unlink_element(element=None, obj=None):
|
def unlink_element(element=None, obj=None):
|
||||||
if element is None:
|
if element is None:
|
||||||
@@ -358,6 +373,17 @@ class IfcStore:
|
|||||||
elif obj:
|
elif obj:
|
||||||
obj.BIMObjectProperties.ifc_definition_id = 0
|
obj.BIMObjectProperties.ifc_definition_id = 0
|
||||||
|
|
||||||
|
if IfcStore.history:
|
||||||
|
data = {}
|
||||||
|
if element:
|
||||||
|
data["id"] = element.id()
|
||||||
|
data["guid"] = getattr(element, "GlobalId", None)
|
||||||
|
if obj:
|
||||||
|
data["obj"] = obj.name
|
||||||
|
IfcStore.history[-1]["operations"].append(
|
||||||
|
{"rollback": IfcStore.rollback_unlink_element, "commit": IfcStore.commit_unlink_element, "data": data}
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def execute_ifc_operator(operator, context):
|
def execute_ifc_operator(operator, context):
|
||||||
is_top_level_operator = not bool(IfcStore.current_transaction)
|
is_top_level_operator = not bool(IfcStore.current_transaction)
|
||||||
|
|||||||
Reference in New Issue
Block a user