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:
Paul Beckingham 2011-08-13 21:53:10 -04:00
parent cb366e0270
commit be0522d567
6 changed files with 12 additions and 30 deletions

View file

@ -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;
}