protect cache lookups in pcbnew/zone by locking the mutex before calling find, fix #17237
This commit is contained in:
parent
1b5e18d95f
commit
d1867bd728
|
@ -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