mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 00:03:17 +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):
|
def execute_ifc_operator(operator, context):
|
||||||
is_top_level_operator = not bool(IfcStore.current_transaction)
|
is_top_level_operator = not bool(IfcStore.current_transaction)
|
||||||
|
|
||||||
|
file = IfcStore.get_file()
|
||||||
|
if not file:
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
if is_top_level_operator:
|
if is_top_level_operator:
|
||||||
IfcStore.begin_transaction(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
|
# 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)
|
IfcStore.add_transaction_operation(operator, rollback=lambda data: True, commit=lambda data: True)
|
||||||
else:
|
else:
|
||||||
@@ -195,9 +199,9 @@ class IfcStore:
|
|||||||
result = getattr(operator, "_execute")(context)
|
result = getattr(operator, "_execute")(context)
|
||||||
|
|
||||||
if is_top_level_operator:
|
if is_top_level_operator:
|
||||||
IfcStore.get_file().end_transaction()
|
file.end_transaction()
|
||||||
IfcStore.add_transaction_operation(
|
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)
|
IfcStore.end_transaction(operator)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user