mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Annotation Collisions
- Annotation timestamps are now incremented until unique. This prevents rapid, successive annotations colliding. The kind that occur during unit tests and when using UI wrapper programs. - Removed 'sleep' commands in unit tests that were added to circumvent this. This speeds up the test suite somewhat.
This commit is contained in:
parent
cb366e0270
commit
be0522d567
6 changed files with 12 additions and 30 deletions
15
src/Task.cpp
15
src/Task.cpp
|
@ -762,12 +762,21 @@ void Task::setAnnotations (const std::map <std::string, std::string>& annotation
|
|||
// The timestamp is part of the name:
|
||||
// annotation_1234567890:"..."
|
||||
//
|
||||
// Note that the time is incremented (one second) in order to find a unique
|
||||
// timestamp.
|
||||
void Task::addAnnotation (const std::string& description)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << "annotation_" << time (NULL);
|
||||
time_t now = time (NULL);
|
||||
std::string key;
|
||||
|
||||
(*this)[s.str ()] = description;
|
||||
do
|
||||
{
|
||||
key = "annotation_" + format ((int) now);
|
||||
++now;
|
||||
}
|
||||
while (has (key));
|
||||
|
||||
(*this)[key] = description;
|
||||
recalc_urgency = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue