From d54c7e090ee713080b269f19fca6de122fa89ab1 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Fri, 19 Nov 2021 22:46:55 -0500 Subject: [PATCH] Task: Correctly handle bulk removal of virtual tags/depends attributes This edge case would happen if a user issued a following command $ task 1 mod depends: or $ task 1 mod tags: which would not perform as expected for tasks with non-empty depends / tags attributes. The problem under the hood is the fact that current synchronization between 'tags" attribute and its constituent decomposed `tag_X` attributes is performed in a way where the set of tags obtained from `tag_X` attributes is taken as the source of truth. If the legacy 'tags:' attribute was set to empty, the fixTags() method would then restore its previous value from the `tag_X` attributes, effectively leading to a no-op. The same happens with dependencies. The fix here is to detect removal of depends and tags attributes, and instead of setting the legacy attributes to empty values, we iteratively remove all tags/dependencies. Closes #2655. --- src/Task.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Task.cpp b/src/Task.cpp index 8c7c6ffdb..ec7e4a8eb 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -2276,6 +2276,19 @@ void Task::modify (modType type, bool text_required /* = false */) value == "''" || value == "\"\"") { + // Special case: Handle bulk removal of 'tags' and 'depends" virtual + // attributes + if (name == "depends") + { + for (auto dep: getDependencyUUIDs ()) + removeDependency(dep); + } + else if (name == "tags") + { + for (auto tag: getTags ()) + removeTag(tag); + } + // ::composeF4 will skip if the value is blank, but the presence of // the attribute will prevent ::validate from applying defaults. if ((has (name) && get (name) != "") ||