TW-1688: task fails to import

- Thanks to Rainer Müller.
This commit is contained in:
Paul Beckingham 2015-09-11 07:49:29 -04:00
parent f55afe33d7
commit cd736a0d70
4 changed files with 30 additions and 9 deletions

View file

@ -67,15 +67,14 @@ void dependencyGetBlocking (const Task& task, std::vector <Task>& blocking)
// Returns true if the supplied task adds a cycle to the dependency chain.
bool dependencyIsCircular (const Task& task)
{
std::stack <Task> s;
std::vector <std::string> deps_current;
std::string task_uuid = task.get ("uuid");
std::stack <Task> s;
s.push (task);
while (!s.empty ())
while (! s.empty ())
{
Task& current = s.top ();
std::vector <std::string> deps_current;
current.getDependencies (deps_current);
// This is a basic depth first search that always terminates given the
@ -85,16 +84,18 @@ bool dependencyIsCircular (const Task& task)
// function, this is a reasonable assumption.
for (unsigned int i = 0; i < deps_current.size (); i++)
{
context.tdb2.get (deps_current[i], current);
if (task_uuid == current.get ("uuid"))
if (context.tdb2.get (deps_current[i], current))
{
if (task_uuid == current.get ("uuid"))
{
// Cycle found, initial task reached for the second time!
return true;
}
s.push (current);
s.push (current);
}
}
s.pop ();
}