Return prematurely from operator if no file is set

This commit is contained in:
Gorgious
2021-07-30 09:38:29 +02:00
parent 6782c47d86
commit f876cfbcef
+7 -3
View File
@@ -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)