From 34f490fb7fa2a4c6ed95d4d46c89a3213757090c Mon Sep 17 00:00:00 2001 From: Conatum Date: Fri, 18 Aug 2023 20:20:50 +0300 Subject: [PATCH] fix (tasklist): Cut cycles in label alg. --- src/modules/tasklist/tasklist.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/tasklist/tasklist.py b/src/modules/tasklist/tasklist.py index 87b705fb..4e53ffda 100644 --- a/src/modules/tasklist/tasklist.py +++ b/src/modules/tasklist/tasklist.py @@ -61,8 +61,18 @@ class Tasklist: label = labels[tid] else: pid = task.parentid + if (parent := taskmap.get(pid, None)) is None: + # Case where parent is not a valid task + pid = None + if pid is not None and pid in counters and pid not in labels: + # Parent has started being labelled before + # But has not finished! + # This implies a cycle (i.e. tasklist is not a tree) + # Prune the cycle + pid = None + counters[pid] = i = counters.get(pid, 0) + 1 - if pid is not None and (parent := taskmap.get(pid, None)) is not None: + if pid is not None: plabel = self._label(parent, taskmap, labels, counters) else: plabel = ()