pcbnew: Thread safety for connections

Moving the mutex to the class from a local variable protects the
connectivity list against corruption from multiple threads computing the
ratsnest.
This commit is contained in:
Seth Hillbrand 2018-06-20 23:25:01 -07:00
parent e2122db587
commit dd436b658a
2 changed files with 3 additions and 4 deletions

View File

@ -305,8 +305,6 @@ bool CN_CONNECTIVITY_ALGO::Add( BOARD_ITEM* aItem )
void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones )
{
std::mutex cnListLock;
#ifdef CONNECTIVITY_DEBUG
printf("Search start\n");
#endif
@ -353,7 +351,7 @@ void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones )
auto item = m_itemList[i];
if( item->Dirty() )
{
CN_VISITOR visitor( item, &cnListLock );
CN_VISITOR visitor( item, &m_listLock );
m_itemList.FindNearby( item, visitor );
if( aIncludeZones )
@ -383,7 +381,7 @@ void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones )
if( zoneItem->Dirty() )
{
CN_VISITOR visitor( item, &cnListLock );
CN_VISITOR visitor( item, &m_listLock );
m_itemList.FindNearby( item, visitor );
m_zoneList.FindNearby( item, visitor );
}

View File

@ -679,6 +679,7 @@ public:
std::list<CN_ITEM*> m_items;
};
std::mutex m_listLock;
CN_LIST m_itemList;
CN_ZONE_LIST m_zoneList;