protect cache lookups in pcbnew/zone by locking the mutex before calling find, fix #17237
This commit is contained in:
parent
7520a8b316
commit
4590455ab2
|
@ -344,14 +344,13 @@ const BOX2I ZONE::GetBoundingBox() const
|
|||
if( const BOARD* board = GetBoard() )
|
||||
{
|
||||
std::unordered_map<const ZONE*, BOX2I>& cache = board->m_ZoneBBoxCache;
|
||||
std::unique_lock<std::mutex> cacheLock( const_cast<BOARD*>( board )->m_CachesMutex );
|
||||
auto cacheIter = cache.find( this );
|
||||
|
||||
if( cacheIter != cache.end() )
|
||||
return cacheIter->second;
|
||||
|
||||
BOX2I bbox = m_Poly->BBox();
|
||||
|
||||
std::unique_lock<std::mutex> cacheLock( const_cast<BOARD*>( board )->m_CachesMutex );
|
||||
cache[ this ] = bbox;
|
||||
|
||||
return bbox;
|
||||
|
@ -365,12 +364,11 @@ void ZONE::CacheBoundingBox()
|
|||
{
|
||||
BOARD* board = GetBoard();
|
||||
std::unordered_map<const ZONE*, BOX2I>& cache = board->m_ZoneBBoxCache;
|
||||
|
||||
auto cacheIter = cache.find( this );
|
||||
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
||||
auto cacheIter = cache.find( this );
|
||||
|
||||
if( cacheIter == cache.end() )
|
||||
{
|
||||
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
||||
cache[ this ] = m_Poly->BBox();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue