From 7224a8111dc339b634f6dd123cb8b6aa4bd54f9d Mon Sep 17 00:00:00 2001 From: Diego Garcia Gangl Date: Sat, 9 Jul 2022 23:49:52 -0300 Subject: [PATCH] W fix subtasks --- GTG/gtk/editor/taskview.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/GTG/gtk/editor/taskview.py b/GTG/gtk/editor/taskview.py index c77cc23158..a194c29ebe 100644 --- a/GTG/gtk/editor/taskview.py +++ b/GTG/gtk/editor/taskview.py @@ -760,10 +760,15 @@ def insert(self, text: str) -> None: # Insert subtasks. Remove existing subtasks from the list, we # will delete the rest at the end for sub in subtasks.copy(): - self.insert_existing_subtask(*sub) + try: + _sub = self.ds.tasks.get(sub[0]) + self.insert_existing_subtask(_sub, sub[1]) - if sub[0] in self.ds.tasks.lookup.keys(): - subtasks.remove(sub) + if sub[0] in self.ds.tasks.lookup.keys(): + subtasks.remove(sub) + except KeyError: + # The task has been deleted + pass # Remove non-existing subtasks (subtasks that have been deleted) for sub in subtasks: