From 23ac9895ab0de5b1f02aab64a46c8125aa30b82c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 2 Feb 2016 01:03:19 -0500 Subject: [PATCH] TW-1763: Removing the due date of a task with no due date modifies the task - Thanks to Scott Kostyshak. --- ChangeLog | 2 ++ src/Task.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index eea0aa2b6..84ec73fdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,6 +52,8 @@ (thanks to Misty De Meo). - TW-1752 cleanup of diag output (thanks to David Patrick). - TW-1756 The columns.t unit test fails two tests after 2300 local. +- TW-1763 Removing the due date of a task with no due date modifies the task + (thanks to Scott Kostyshak). - Fixed broken build for Cygwin and older GCC (thanks to Richard Boß). - The default configuration is now 256-color only. - The 'columns' report now shows whether a column is modifiable or read only. diff --git a/src/Task.cpp b/src/Task.cpp index 41da7523d..eda9f9371 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -105,7 +105,7 @@ bool Task::operator== (const Task& other) if (data.size () != other.data.size ()) return false; - for (auto& i : data) + for (const auto& i : data) if (i.first != "uuid" && i.second != other.get (i.first)) return false; @@ -780,10 +780,12 @@ std::string Task::composeF4 () const bool first = true; for (auto it : data) { + // Orphans have no type, treat as string. std::string type = Task::attributes[it.first]; if (type == "") type = "string"; + // If there is a value. if (it.second != "") { ff4 += (first ? "" : " "); @@ -1967,9 +1969,15 @@ void Task::modify (modType type, bool text_required /* = false */) { // ::composeF4 will skip if the value is blank, but the presence of // the attribute will prevent ::validate from applying defaults. - set (name, ""); + if ((has (name) && get (name) != "") || + (name == "due" && context.config.has ("default.due")) || + (name == "project" && context.config.has ("default.project"))) + { + mods = true; + set (name, ""); + } + context.debug (label + name + " <-- ''"); - mods = true; } else {