mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
TDB2
- Now updates the task ID of any new task, therefore avoiding off-by-one errors that occur when code calls TDB2::next_id.
This commit is contained in:
parent
45e6512c02
commit
6faf6bb678
4 changed files with 11 additions and 14 deletions
19
src/TDB2.cpp
19
src/TDB2.cpp
|
@ -135,26 +135,23 @@ bool TF2::get (const std::string& uuid, Task& task)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TF2::add_task (const Task& task)
|
||||
void TF2::add_task (Task& task)
|
||||
{
|
||||
Task hookTask (task);
|
||||
context.hooks.onAdd (hookTask);
|
||||
context.hooks.onAdd (task);
|
||||
_tasks.push_back (task); // For subsequent queries
|
||||
_added_tasks.push_back (task); // For commit/synch
|
||||
|
||||
_tasks.push_back (hookTask); // For subsequent queries
|
||||
_added_tasks.push_back (hookTask); // For commit/synch
|
||||
|
||||
int id = task.id;
|
||||
Task::status status = task.getStatus ();
|
||||
if (id == 0 &&
|
||||
if (task.id == 0 &&
|
||||
(status == Task::pending ||
|
||||
status == Task::recurring ||
|
||||
status == Task::waiting))
|
||||
{
|
||||
id = context.tdb2.next_id ();
|
||||
task.id = context.tdb2.next_id ();
|
||||
}
|
||||
|
||||
_I2U[id] = task.get ("uuid");
|
||||
_U2I[task.get ("uuid")] = id;
|
||||
_I2U[task.id] = task.get ("uuid");
|
||||
_U2I[task.get ("uuid")] = task.id;
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue