diff --git a/src/Task.cpp b/src/Task.cpp index 434cd49b3..ec81251de 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -60,7 +60,7 @@ #define APPROACHING_INFINITY 1000 // Close enough. This isn't rocket surgery. -extern Task& contextTask; +extern Task* contextTask; static const float epsilon = 0.000001; #endif @@ -2271,6 +2271,10 @@ void Task::modify (modType type, bool text_required /* = false */) { std::string label = " MODIFICATION "; + // while reading the parse tree, consider DOM references in the context of + // this task + contextTask = this; + // Need this for later comparison. auto originalStatus = getStatus (); diff --git a/src/commands/CmdAdd.cpp b/src/commands/CmdAdd.cpp index dd3ba23b4..21d5475a9 100644 --- a/src/commands/CmdAdd.cpp +++ b/src/commands/CmdAdd.cpp @@ -30,8 +30,6 @@ #include #include -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdAdd::CmdAdd () { @@ -56,7 +54,6 @@ int CmdAdd::execute (std::string& output) // the task is empty, but DOM references can refer to earlier parts of the // command line, e.g., `task add due:20110101 wait:due`. - contextTask = &task; task.modify (Task::modReplace, true); Context::getContext ().tdb2.add (task); diff --git a/src/commands/CmdAnnotate.cpp b/src/commands/CmdAnnotate.cpp index 9812874a2..4a3a17a83 100644 --- a/src/commands/CmdAnnotate.cpp +++ b/src/commands/CmdAnnotate.cpp @@ -33,8 +33,6 @@ #include #include -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdAnnotate::CmdAnnotate () { @@ -84,7 +82,6 @@ int CmdAnnotate::execute (std::string&) task.identifier (true), task.get ("description")); - contextTask = &task; task.modify (Task::modAnnotate, true); if (permission (before.diff (task) + question, filtered.size ())) @@ -105,7 +102,6 @@ int CmdAnnotate::execute (std::string&) auto siblings = Context::getContext ().tdb2.siblings (task); for (auto& sibling : siblings) { - contextTask = &sibling; sibling.modify (Task::modAnnotate, true); Context::getContext ().tdb2.modify (sibling); ++count; @@ -115,7 +111,6 @@ int CmdAnnotate::execute (std::string&) // Annotate the parent Task parent; Context::getContext ().tdb2.get (task.get ("parent"), parent); - contextTask = &parent; parent.modify (Task::modAnnotate, true); Context::getContext ().tdb2.modify (parent); } diff --git a/src/commands/CmdAppend.cpp b/src/commands/CmdAppend.cpp index 39906e789..1ce75447b 100644 --- a/src/commands/CmdAppend.cpp +++ b/src/commands/CmdAppend.cpp @@ -33,8 +33,6 @@ #include #include -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdAppend::CmdAppend () { @@ -84,7 +82,6 @@ int CmdAppend::execute (std::string&) task.identifier (true), task.get ("description")); - contextTask = &task; task.modify (Task::modAppend, true); if (permission (before.diff (task) + question, filtered.size ())) @@ -105,7 +102,6 @@ int CmdAppend::execute (std::string&) std::vector siblings = Context::getContext ().tdb2.siblings (task); for (auto& sibling : siblings) { - contextTask = &sibling; sibling.modify (Task::modAppend, true); Context::getContext ().tdb2.modify (sibling); ++count; @@ -115,7 +111,6 @@ int CmdAppend::execute (std::string&) // Append to the parent Task parent; Context::getContext ().tdb2.get (task.get ("parent"), parent); - contextTask = &parent; parent.modify (Task::modAppend, true); Context::getContext ().tdb2.modify (parent); } diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index 4e4f78c29..8bedab285 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -36,8 +36,6 @@ #define STRING_CMD_DELETE_TASK_R "Deleting recurring task {1} '{2}'." #define STRING_CMD_DELETE_CONFIRM_R "This is a recurring task. Do you want to delete all pending recurrences of this same task?" -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdDelete::CmdDelete () { @@ -89,7 +87,6 @@ int CmdDelete::execute (std::string&) task.identifier (true), task.get ("description")); - contextTask = &task; task.modify (Task::modAnnotate); task.setStatus (Task::deleted); if (! task.has ("end")) @@ -116,7 +113,6 @@ int CmdDelete::execute (std::string&) std::vector siblings = Context::getContext ().tdb2.siblings (task); for (auto& sibling : siblings) { - contextTask = &sibling; sibling.modify (Task::modAnnotate); sibling.setStatus (Task::deleted); if (! sibling.has ("end")) @@ -151,7 +147,6 @@ int CmdDelete::execute (std::string&) { for (auto& child : children) { - contextTask = &child; child.modify (Task::modAnnotate); child.setStatus (Task::deleted); if (! child.has ("end")) diff --git a/src/commands/CmdDone.cpp b/src/commands/CmdDone.cpp index dd2e64333..f579364ac 100644 --- a/src/commands/CmdDone.cpp +++ b/src/commands/CmdDone.cpp @@ -33,8 +33,6 @@ #include #include -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdDone::CmdDone () { @@ -87,7 +85,6 @@ int CmdDone::execute (std::string&) task.identifier (true), task.get ("description")); - contextTask = &task; task.modify (Task::modAnnotate); task.setStatus (Task::completed); if (! task.has ("end")) diff --git a/src/commands/CmdDuplicate.cpp b/src/commands/CmdDuplicate.cpp index 8ed3aa5d5..46f1070e3 100644 --- a/src/commands/CmdDuplicate.cpp +++ b/src/commands/CmdDuplicate.cpp @@ -33,8 +33,6 @@ #include #include -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdDuplicate::CmdDuplicate () { @@ -102,7 +100,6 @@ int CmdDuplicate::execute (std::string&) dup.setStatus (Task::pending); // Does not inherit status. // Must occur after Task::recurring check. - contextTask = &dup; dup.modify (Task::modAnnotate); if (permission (format ("Duplicate task {1} '{2}'?", diff --git a/src/commands/CmdModify.cpp b/src/commands/CmdModify.cpp index 236b45fa8..cb407367d 100644 --- a/src/commands/CmdModify.cpp +++ b/src/commands/CmdModify.cpp @@ -36,8 +36,6 @@ #define STRING_CMD_MODIFY_TASK_R "Modifying recurring task {1} '{2}'." #define STRING_CMD_MODIFY_RECUR "This is a recurring task. Do you want to modify all pending recurrences of this same task?" -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdModify::CmdModify () { @@ -79,7 +77,6 @@ int CmdModify::execute (std::string&) for (auto& task : filtered) { Task before (task); - contextTask = &task; task.modify (Task::modReplace); if (before != task) @@ -177,7 +174,6 @@ int CmdModify::modifyRecurrenceSiblings ( for (auto& sibling : siblings) { Task alternate (sibling); - contextTask = &sibling; sibling.modify (Task::modReplace); updateRecurrenceMask (sibling); ++count; @@ -191,7 +187,6 @@ int CmdModify::modifyRecurrenceSiblings ( // Modify the parent Task parent; Context::getContext ().tdb2.get (task.get ("parent"), parent); - contextTask = &parent; parent.modify (Task::modReplace); Context::getContext ().tdb2.modify (parent); } @@ -215,7 +210,6 @@ int CmdModify::modifyRecurrenceParent ( for (auto& child : children) { Task alternate (child); - contextTask = &child; child.modify (Task::modReplace); updateRecurrenceMask (child); Context::getContext ().tdb2.modify (child); diff --git a/src/commands/CmdPrepend.cpp b/src/commands/CmdPrepend.cpp index 847fef5d7..0e59d5a30 100644 --- a/src/commands/CmdPrepend.cpp +++ b/src/commands/CmdPrepend.cpp @@ -33,8 +33,6 @@ #include #include -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdPrepend::CmdPrepend () { @@ -84,7 +82,6 @@ int CmdPrepend::execute (std::string&) task.identifier (true), task.get ("description")); - contextTask = &task; task.modify (Task::modPrepend, true); if (permission (before.diff (task) + question, filtered.size ())) @@ -105,7 +102,6 @@ int CmdPrepend::execute (std::string&) std::vector siblings = Context::getContext ().tdb2.siblings (task); for (auto& sibling : siblings) { - contextTask = &sibling; sibling.modify (Task::modPrepend, true); Context::getContext ().tdb2.modify (sibling); ++count; @@ -115,7 +111,6 @@ int CmdPrepend::execute (std::string&) // Prepend to the parent Task parent; Context::getContext ().tdb2.get (task.get ("parent"), parent); - contextTask = &parent; parent.modify (Task::modPrepend, true); Context::getContext ().tdb2.modify (parent); } diff --git a/src/commands/CmdStart.cpp b/src/commands/CmdStart.cpp index b6636dc50..6329c8129 100644 --- a/src/commands/CmdStart.cpp +++ b/src/commands/CmdStart.cpp @@ -33,8 +33,6 @@ #include #include -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdStart::CmdStart () { @@ -85,7 +83,6 @@ int CmdStart::execute (std::string&) std::string question = format ("Start task {1} '{2}'?", task.identifier (true), task.get ("description")); - contextTask = &task; task.modify (Task::modAnnotate); task.setAsNow ("start"); diff --git a/src/commands/CmdStop.cpp b/src/commands/CmdStop.cpp index 020757230..f9d1cec6d 100644 --- a/src/commands/CmdStop.cpp +++ b/src/commands/CmdStop.cpp @@ -32,8 +32,6 @@ #include #include -extern Task* contextTask; - //////////////////////////////////////////////////////////////////////////////// CmdStop::CmdStop () { @@ -83,7 +81,6 @@ int CmdStop::execute (std::string&) task.identifier (true), task.get ("description")); - contextTask = &task; task.modify (Task::modAnnotate); task.remove ("start");