mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
Better thread safety for zone boundingbox caches.
This commit is contained in:
parent
adbbceacda
commit
97d4df4154
@ -1151,7 +1151,6 @@ public:
|
|||||||
std::unordered_map< wxString, LSET > m_LayerExpressionCache;
|
std::unordered_map< wxString, LSET > m_LayerExpressionCache;
|
||||||
std::unordered_map<ZONE*, std::unique_ptr<DRC_RTREE>> m_CopperZoneRTreeCache;
|
std::unordered_map<ZONE*, std::unique_ptr<DRC_RTREE>> m_CopperZoneRTreeCache;
|
||||||
std::unique_ptr<DRC_RTREE> m_CopperItemRTreeCache;
|
std::unique_ptr<DRC_RTREE> m_CopperItemRTreeCache;
|
||||||
|
|
||||||
mutable std::unordered_map<const ZONE*, BOX2I> m_ZoneBBoxCache;
|
mutable std::unordered_map<const ZONE*, BOX2I> m_ZoneBBoxCache;
|
||||||
|
|
||||||
// ------------ DRC caches -------------
|
// ------------ DRC caches -------------
|
||||||
|
@ -308,16 +308,19 @@ bool ZONE::IsOnLayer( PCB_LAYER_ID aLayer ) const
|
|||||||
|
|
||||||
const BOX2I ZONE::GetBoundingBox() const
|
const BOX2I ZONE::GetBoundingBox() const
|
||||||
{
|
{
|
||||||
if( const BOARD* parent = GetBoard() )
|
if( const BOARD* board = GetBoard() )
|
||||||
{
|
{
|
||||||
std::unordered_map<const ZONE*, BOX2I>& cache = parent->m_ZoneBBoxCache;
|
std::unordered_map<const ZONE*, BOX2I>& cache = board->m_ZoneBBoxCache;
|
||||||
auto cacheIter = cache.find( this );
|
auto cacheIter = cache.find( this );
|
||||||
|
|
||||||
if( cacheIter != cache.end() )
|
if( cacheIter != cache.end() )
|
||||||
return cacheIter->second;
|
return cacheIter->second;
|
||||||
|
|
||||||
BOX2I bbox = m_Poly->BBox();
|
BOX2I bbox = m_Poly->BBox();
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> cacheLock( const_cast<BOARD*>( board )->m_CachesMutex );
|
||||||
cache[ this ] = bbox;
|
cache[ this ] = bbox;
|
||||||
|
|
||||||
return bbox;
|
return bbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,13 +330,17 @@ const BOX2I ZONE::GetBoundingBox() const
|
|||||||
|
|
||||||
void ZONE::CacheBoundingBox()
|
void ZONE::CacheBoundingBox()
|
||||||
{
|
{
|
||||||
std::unordered_map<const ZONE*, BOX2I>& cache = GetBoard()->m_ZoneBBoxCache;
|
BOARD* board = GetBoard();
|
||||||
|
std::unordered_map<const ZONE*, BOX2I>& cache = board->m_ZoneBBoxCache;
|
||||||
|
|
||||||
auto cacheIter = cache.find( this );
|
auto cacheIter = cache.find( this );
|
||||||
|
|
||||||
if( cacheIter == cache.end() )
|
if( cacheIter == cache.end() )
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
||||||
cache[ this ] = m_Poly->BBox();
|
cache[ this ] = m_Poly->BBox();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int ZONE::GetThermalReliefGap( PAD* aPad, wxString* aSource ) const
|
int ZONE::GetThermalReliefGap( PAD* aPad, wxString* aSource ) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user