From f876cfbcef040f19672bbc404ea2aa5131b3a616 Mon Sep 17 00:00:00 2001 From: Gorgious Date: Fri, 30 Jul 2021 09:38:29 +0200 Subject: [PATCH] Return prematurely from operator if no file is set --- src/blenderbim/blenderbim/bim/ifc.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/ifc.py b/src/blenderbim/blenderbim/bim/ifc.py index 6390ac630f..3f20975fe3 100644 --- a/src/blenderbim/blenderbim/bim/ifc.py +++ b/src/blenderbim/blenderbim/bim/ifc.py @@ -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)