58f553a9ca requires that cache be layer-sensitive.

Fixes https://gitlab.com/kicad/code/kicad/issues/11814
This commit is contained in:
Jeff Young 2022-06-15 00:10:01 +01:00
parent b56917210d
commit 5e80e2a421
3 changed files with 18 additions and 13 deletions

View File

@ -1071,16 +1071,16 @@ public:
}; };
// ------------ Run-time caches ------------- // ------------ Run-time caches -------------
std::mutex m_CachesMutex; std::mutex m_CachesMutex;
std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideCourtyardCache; std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideCourtyardCache;
std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideFCourtyardCache; std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideFCourtyardCache;
std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideBCourtyardCache; std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideBCourtyardCache;
std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideAreaCache; std::map< std::tuple<BOARD_ITEM*, BOARD_ITEM*, PCB_LAYER_ID>, bool > m_InsideAreaCache;
std::map< wxString, LSET > m_LayerExpressionCache; std::map< wxString, LSET > m_LayerExpressionCache;
std::map< ZONE*, std::unique_ptr<DRC_RTREE> > m_CopperZoneRTrees; std::map< ZONE*, std::unique_ptr<DRC_RTREE> > m_CopperZoneRTrees;
ZONE* m_SolderMask; ZONE* m_SolderMask;
private: private:
// The default copy constructor & operator= are inadequate, // The default copy constructor & operator= are inadequate,

View File

@ -154,11 +154,15 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
if( m_drcEngine->IsCancelled() ) if( m_drcEngine->IsCancelled() )
break; break;
std::pair<BOARD_ITEM*, BOARD_ITEM*> key( ruleArea, copperZone ); std::tuple<BOARD_ITEM*, BOARD_ITEM*, PCB_LAYER_ID> key( ruleArea,
copperZone,
UNDEFINED_LAYER );
{ {
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex ); std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
board->m_InsideAreaCache[ key ] = isInside; board->m_InsideAreaCache[ key ] = isInside;
} }
done.fetch_add( 1 ); done.fetch_add( 1 );
} }

View File

@ -584,10 +584,11 @@ bool isInsideArea( BOARD_ITEM* aItem, const EDA_RECT& aItemBBox, PCB_EXPR_CONTEX
if( !aArea || aArea == aItem || aArea->GetParent() == aItem ) if( !aArea || aArea == aItem || aArea->GetParent() == aItem )
return false; return false;
BOARD* board = aArea->GetBoard(); BOARD* board = aArea->GetBoard();
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex ); std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
std::pair<BOARD_ITEM*, BOARD_ITEM*> key( aArea, aItem ); PCB_LAYER_ID layer = aCtx->GetLayer();
auto i = board->m_InsideAreaCache.find( key ); std::tuple<BOARD_ITEM*, BOARD_ITEM*, PCB_LAYER_ID> key( aArea, aItem, layer );
auto i = board->m_InsideAreaCache.find( key );
if( i != board->m_InsideAreaCache.end() ) if( i != board->m_InsideAreaCache.end() )
return i->second; return i->second;