Commit dacfcd24 authored by Lorenz Meier's avatar Lorenz Meier

Fix race in opmapcontrol

parent 7fae1b1f
...@@ -100,7 +100,7 @@ void TileMatrix::Clear() ...@@ -100,7 +100,7 @@ void TileMatrix::Clear()
void TileMatrix::ClearPointsNotIn(QList<Point>list) void TileMatrix::ClearPointsNotIn(QList<Point>list)
{ {
removals.clear(); removals.clear();
mutex.lock(); QMutexLocker lock(&mutex);
foreach(Point p, matrix.keys()) foreach(Point p, matrix.keys())
{ {
if(!list.contains(p)) if(!list.contains(p))
...@@ -111,14 +111,12 @@ void TileMatrix::ClearPointsNotIn(QList<Point>list) ...@@ -111,14 +111,12 @@ void TileMatrix::ClearPointsNotIn(QList<Point>list)
mutex.unlock(); mutex.unlock();
foreach(Point p,removals) foreach(Point p,removals)
{ {
Tile* t=TileAt(p); Tile* t=matrix.value(p, 0);
if(t!=0) if(t!=0)
{ {
mutex.lock();
delete t; delete t;
t=0; t=0;
matrix.remove(p); matrix.remove(p);
mutex.unlock();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment