From 02a62a943ce20ab12c8bad16ff143c29a7391d51 Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Tue, 4 Jan 2022 03:03:39 +0100 Subject: [PATCH] Fix #1717 : Disable task editing if task was deleted as a result of deleting its parent (#1936) * Disable task editing if task was deleted as a result of deleting its parent * Optimize logic for bigger number of tasks * Don't try to disable editing if not editing in the first place --- .../blenderbim/bim/module/sequence/operator.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/module/sequence/operator.py b/src/blenderbim/blenderbim/bim/module/sequence/operator.py index da7379cca9..d37ec2ff32 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/operator.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/operator.py @@ -513,13 +513,25 @@ class RemoveTask(bpy.types.Operator): def _execute(self, context): props = context.scene.BIMWorkScheduleProperties self.file = IfcStore.get_file() + edited_task_ifc = self.file.by_id(props.active_task_id) if props.active_task_id else None + ifcopenshell.api.run( "sequence.remove_task", self.file, - task=IfcStore.get_file().by_id(self.task), + task=self.file.by_id(self.task), ) Data.load(self.file) bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id) + + if edited_task_ifc: + if not any( + task + for task in context.scene.BIMTaskTreeProperties.tasks + if task.ifc_definition_id == props.active_task_id + and self.file.by_id(props.active_task_id) == edited_task_ifc + ): # Task was deleted + bpy.ops.bim.disable_editing_task() + return {"FINISHED"}