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