From ac833c183a6e773eee38f870d7d1fa9c7e1de504 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 14 Sep 2014 14:56:54 -0400 Subject: [PATCH] TDB2 - TDB2::add no longer assumes that adding one task results in only one task begin added, as hook processing may expand the set. --- src/TDB2.cpp | 105 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 37 deletions(-) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 73b4039ac..b89d63fde 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -560,31 +560,49 @@ void TDB2::add (Task& task, bool add_to_backlog /* = true */) { // Ensure the task is consistent, and provide defaults if necessary. task.validate (); + std::string uuid = task.get ("uuid"); // If the tasks are loaded, then verify that this uuid is not already in // the file. - if (!verifyUniqueUUID (task.get ("uuid"))) - throw format (STRING_TDB2_UUID_NOT_UNIQUE, task.get ("uuid")); + if (!verifyUniqueUUID (uuid)) + throw format (STRING_TDB2_UUID_NOT_UNIQUE, uuid); - // Add new task to either pending or completed. - std::string status = task.get ("status"); - if (status == "completed" || - status == "deleted") - completed.add_task (task); - else - pending.add_task (task); + // Create a vector tasks, as hooks can cause them to multiply. + std::vector toAdd; + toAdd.push_back (task); - // Add undo data lines: - // time