]> git.lyx.org Git - lyx.git/blobdiff - src/Graph.cpp
Move bind file format tag to LyXAction.cpp, and rename it.
[lyx.git] / src / Graph.cpp
index bfb61dc3f3456bdad25e1df35c6e79dcc49a766e..aaac662dc684ab7e0b62971bd651382192445492 100644 (file)
@@ -57,6 +57,8 @@ void Graph::clearPaths()
 vector<int> const
        Graph::getReachableTo(int target, bool clear_visited)
 {
+       Mutex::Locker lock(&mutex_);
+
        vector<int> result;
        if (!bfs_init(target, clear_visited))
                return result;
@@ -92,6 +94,8 @@ vector<int> const
        Graph::getReachable(int from, bool only_viewable,
                bool clear_visited)
 {
+       Mutex::Locker lock(&mutex_);
+
        vector<int> result;
        if (!bfs_init(from, clear_visited))
                return result;
@@ -128,6 +132,8 @@ vector<int> const
 
 bool Graph::isReachable(int from, int to)
 {
+       Mutex::Locker lock(&mutex_);
+
        if (from == to)
                return true;
 
@@ -159,12 +165,13 @@ bool Graph::isReachable(int from, int to)
 
 Graph::EdgePath const Graph::getPath(int from, int to)
 {
-       static const EdgePath path;
+       Mutex::Locker lock(&mutex_);
+
        if (from == to)
-               return path;
+               return EdgePath();
 
        if (to < 0 || !bfs_init(from))
-               return path;
+               return EdgePath();
 
        clearPaths();
        while (!Q_.empty()) {
@@ -193,12 +200,14 @@ Graph::EdgePath const Graph::getPath(int from, int to)
                }
        }
        // failure
-       return path;
+       return EdgePath();
 }
 
 
 void Graph::init(int size)
 {
+       Mutex::Locker lock(&mutex_);
+
        vertices_ = vector<Vertex>(size);
        arrows_.clear();
        numedges_ = 0;
@@ -207,6 +216,8 @@ void Graph::init(int size)
 
 void Graph::addEdge(int from, int to)
 {
+       Mutex::Locker lock(&mutex_);
+
        arrows_.push_back(Arrow(from, to, numedges_));
        numedges_++;
        Arrow * ar = &(arrows_.back());