mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Return prematurely from operator if no file is set
This commit is contained in:
@@ -184,9 +184,13 @@ class IfcStore:
|
||||
def execute_ifc_operator(operator, context):
|
||||
is_top_level_operator = not bool(IfcStore.current_transaction)
|
||||
|
||||
file = IfcStore.get_file()
|
||||
if not file:
|
||||
return {'FINISHED'}
|
||||
|
||||
if is_top_level_operator:
|
||||
IfcStore.begin_transaction(operator)
|
||||
IfcStore.get_file().begin_transaction()
|
||||
file.begin_transaction()
|
||||
# This empty transaction ensures that each operator has at least one transaction
|
||||
IfcStore.add_transaction_operation(operator, rollback=lambda data: True, commit=lambda data: True)
|
||||
else:
|
||||
@@ -195,9 +199,9 @@ class IfcStore:
|
||||
result = getattr(operator, "_execute")(context)
|
||||
|
||||
if is_top_level_operator:
|
||||
IfcStore.get_file().end_transaction()
|
||||
file.end_transaction()
|
||||
IfcStore.add_transaction_operation(
|
||||
operator, rollback=lambda d: IfcStore.get_file().undo(), commit=lambda d: IfcStore.get_file().redo()
|
||||
operator, rollback=lambda d: file.undo(), commit=lambda d: file.redo()
|
||||
)
|
||||
IfcStore.end_transaction(operator)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user