From 5e80e2a421b2af1e26d0be57dc05f803d41526a3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 15 Jun 2022 00:10:01 +0100 Subject: [PATCH] 58f553a9cad972363c21209285bb4b1b142f95a0 requires that cache be layer-sensitive. Fixes https://gitlab.com/kicad/code/kicad/issues/11814 --- pcbnew/board.h | 16 ++++++++-------- pcbnew/drc/drc_test_provider_disallow.cpp | 6 +++++- pcbnew/pcb_expr_evaluator.cpp | 9 +++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/pcbnew/board.h b/pcbnew/board.h index 5342320a94..8df5df798b 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -1071,16 +1071,16 @@ public: }; // ------------ Run-time caches ------------- - std::mutex m_CachesMutex; - std::map< std::pair, bool > m_InsideCourtyardCache; - std::map< std::pair, bool > m_InsideFCourtyardCache; - std::map< std::pair, bool > m_InsideBCourtyardCache; - std::map< std::pair, bool > m_InsideAreaCache; - std::map< wxString, LSET > m_LayerExpressionCache; + std::mutex m_CachesMutex; + std::map< std::pair, bool > m_InsideCourtyardCache; + std::map< std::pair, bool > m_InsideFCourtyardCache; + std::map< std::pair, bool > m_InsideBCourtyardCache; + std::map< std::tuple, bool > m_InsideAreaCache; + std::map< wxString, LSET > m_LayerExpressionCache; - std::map< ZONE*, std::unique_ptr > m_CopperZoneRTrees; + std::map< ZONE*, std::unique_ptr > m_CopperZoneRTrees; - ZONE* m_SolderMask; + ZONE* m_SolderMask; private: // The default copy constructor & operator= are inadequate, diff --git a/pcbnew/drc/drc_test_provider_disallow.cpp b/pcbnew/drc/drc_test_provider_disallow.cpp index 4b7ac2617e..7e8873830f 100644 --- a/pcbnew/drc/drc_test_provider_disallow.cpp +++ b/pcbnew/drc/drc_test_provider_disallow.cpp @@ -154,11 +154,15 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run() if( m_drcEngine->IsCancelled() ) break; - std::pair key( ruleArea, copperZone ); + std::tuple key( ruleArea, + copperZone, + UNDEFINED_LAYER ); + { std::unique_lock cacheLock( board->m_CachesMutex ); board->m_InsideAreaCache[ key ] = isInside; } + done.fetch_add( 1 ); } diff --git a/pcbnew/pcb_expr_evaluator.cpp b/pcbnew/pcb_expr_evaluator.cpp index 5fca5872b9..af65a93f20 100644 --- a/pcbnew/pcb_expr_evaluator.cpp +++ b/pcbnew/pcb_expr_evaluator.cpp @@ -584,10 +584,11 @@ bool isInsideArea( BOARD_ITEM* aItem, const EDA_RECT& aItemBBox, PCB_EXPR_CONTEX if( !aArea || aArea == aItem || aArea->GetParent() == aItem ) return false; - BOARD* board = aArea->GetBoard(); - std::unique_lock cacheLock( board->m_CachesMutex ); - std::pair key( aArea, aItem ); - auto i = board->m_InsideAreaCache.find( key ); + BOARD* board = aArea->GetBoard(); + std::unique_lock cacheLock( board->m_CachesMutex ); + PCB_LAYER_ID layer = aCtx->GetLayer(); + std::tuple key( aArea, aItem, layer ); + auto i = board->m_InsideAreaCache.find( key ); if( i != board->m_InsideAreaCache.end() ) return i->second;