From 3800bae2815a9e5a9e07fb8ea7461a4dfa179a36 Mon Sep 17 00:00:00 2001 From: JamesJCode <13408010-JamesJCode@users.noreply.gitlab.com> Date: Mon, 23 Dec 2024 15:29:29 +0000 Subject: [PATCH] Enforce thread safety in clearance and creepage checks Previously, these checks injected a custom handler to add graphic objects to a DRC marker. This was not thread-safe and was causing non-deterministic crashes. The DRC reporting methods now accept a customer handler which is called on the newly created PCB_MARKER within the commit context. This defaults to nullptr for DRC checks which do not require graphics or other additional processing. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19282 --- pcbnew/drc/drc_engine.cpp | 9 ++---- pcbnew/drc/drc_engine.h | 32 +++---------------- pcbnew/drc/drc_test_provider.cpp | 10 +++--- pcbnew/drc/drc_test_provider.h | 10 +++--- .../drc/drc_test_provider_clearance_base.cpp | 27 ++++++---------- pcbnew/drc/drc_test_provider_clearance_base.h | 8 ++--- pcbnew/drc/drc_test_provider_creepage.cpp | 7 ++-- pcbnew/pcbnew_jobs_handler.cpp | 3 +- .../scripting/pcbnew_scripting_helpers.cpp | 3 +- pcbnew/tools/drc_tool.cpp | 8 +++-- .../drc/test_custom_rule_severities.cpp | 3 +- .../pcbnew/drc/test_drc_component_classes.cpp | 3 +- qa/tests/pcbnew/drc/test_drc_copper_conn.cpp | 3 +- .../pcbnew/drc/test_drc_copper_graphics.cpp | 3 +- .../pcbnew/drc/test_drc_copper_sliver.cpp | 3 +- .../pcbnew/drc/test_drc_courtyard_invalid.cpp | 3 +- .../pcbnew/drc/test_drc_courtyard_overlap.cpp | 3 +- .../drc/test_drc_incorrect_text_mirror.cpp | 3 +- .../pcbnew/drc/test_drc_multi_netclasses.cpp | 3 +- qa/tests/pcbnew/drc/test_drc_regressions.cpp | 6 ++-- qa/tests/pcbnew/drc/test_drc_skew.cpp | 3 +- .../pcbnew/drc/test_solder_mask_bridging.cpp | 3 +- qa/tests/pcbnew/test_tracks_cleaner.cpp | 3 +- qa/tests/pcbnew/test_zone_filler.cpp | 10 ++++-- 24 files changed, 76 insertions(+), 93 deletions(-) diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 24f5727a44..949d4e0212 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -90,9 +90,7 @@ DRC_ENGINE::DRC_ENGINE( BOARD* aBoard, BOARD_DESIGN_SETTINGS *aSettings ) : m_errorLimits.resize( DRCE_LAST + 1 ); for( int ii = DRCE_FIRST; ii <= DRCE_LAST; ++ii ) - m_errorLimits[ ii ] = ERROR_LIMIT; - - ClearGraphicsHandler(); + m_errorLimits[ii] = ERROR_LIMIT; } @@ -642,7 +640,6 @@ void DRC_ENGINE::RunTests( EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aT for( DRC_TEST_PROVIDER* provider : m_testProviders ) { ReportAux( wxString::Format( wxT( "Run DRC provider: '%s'" ), provider->GetName() ) ); - provider->SetCommit( aCommit ); if( !provider->RunTests( aUnits ) ) break; @@ -1635,7 +1632,7 @@ bool DRC_ENGINE::IsErrorLimitExceeded( int error_code ) void DRC_ENGINE::ReportViolation( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2I& aPos, - int aMarkerLayer ) + int aMarkerLayer, DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { static std::mutex globalLock; @@ -1644,7 +1641,7 @@ void DRC_ENGINE::ReportViolation( const std::shared_ptr<DRC_ITEM>& aItem, const if( m_violationHandler ) { std::lock_guard<std::mutex> guard( globalLock ); - m_violationHandler( aItem, aPos, aMarkerLayer ); + m_violationHandler( aItem, aPos, aMarkerLayer, aCustomHandler ); } if( m_reporter ) diff --git a/pcbnew/drc/drc_engine.h b/pcbnew/drc/drc_engine.h index 6681ca63d2..7befa7a59d 100644 --- a/pcbnew/drc/drc_engine.h +++ b/pcbnew/drc/drc_engine.h @@ -66,14 +66,11 @@ class DRC_ITEM; class DRC_RULE; class DRC_CONSTRAINT; +typedef std::function<void( PCB_MARKER* aMarker )> DRC_CUSTOM_MARKER_HANDLER; -typedef std::function<void( const std::shared_ptr<DRC_ITEM>& aItem, - const VECTOR2I& aPos, - int aLayer )> DRC_VIOLATION_HANDLER; - - -typedef std::function<void( PCB_MARKER* aMarker )> DRC_GRAPHICS_HANDLER; - +typedef std::function<void( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2I& aPos, + int aLayer, DRC_CUSTOM_MARKER_HANDLER* aCustomHandler )> + DRC_VIOLATION_HANDLER; /** * Design Rule Checker object that performs all the DRC tests. @@ -127,23 +124,6 @@ public: m_violationHandler = DRC_VIOLATION_HANDLER(); } - - /** - * Set an optional DRC graphics handler (receives a PCB_MARKER). - */ - void SetGraphicsHandler( DRC_GRAPHICS_HANDLER aHandler ) - { - m_graphicsHandler = std::move( aHandler ); - } - - void ClearGraphicsHandler() { m_graphicsHandler = DRC_GRAPHICS_HANDLER(); } - - void GraphicsHandler( PCB_MARKER* aMarker ) - { - if( m_graphicsHandler ) - m_graphicsHandler( aMarker ); - } - /** * Set an optional reporter for user-level progress info. */ @@ -193,7 +173,7 @@ public: bool RulesValid() { return m_rulesValid; } void ReportViolation( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2I& aPos, - int aMarkerLayer ); + int aMarkerLayer, DRC_CUSTOM_MARKER_HANDLER* aCustomHandler = nullptr ); bool KeepRefreshing( bool aWait = false ); void AdvanceProgress(); @@ -272,8 +252,6 @@ protected: // constraint -> rule -> provider std::map<DRC_CONSTRAINT_T, std::vector<DRC_ENGINE_CONSTRAINT*>*> m_constraintMap; - - DRC_GRAPHICS_HANDLER m_graphicsHandler; DRC_VIOLATION_HANDLER m_violationHandler; REPORTER* m_reporter; PROGRESS_REPORTER* m_progressReporter; diff --git a/pcbnew/drc/drc_test_provider.cpp b/pcbnew/drc/drc_test_provider.cpp index 1924acfc50..58c37bee65 100644 --- a/pcbnew/drc/drc_test_provider.cpp +++ b/pcbnew/drc/drc_test_provider.cpp @@ -21,7 +21,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <drc/drc_engine.h> #include <drc/drc_item.h> #include <drc/drc_test_provider.h> #include <pcb_track.h> @@ -44,9 +43,7 @@ DRC_TEST_PROVIDER_REGISTRY::~DRC_TEST_PROVIDER_REGISTRY() DRC_TEST_PROVIDER::DRC_TEST_PROVIDER() : - UNITS_PROVIDER( pcbIUScale, EDA_UNITS::MILLIMETRES ), - m_drcEngine( nullptr ), - m_commit (nullptr ) + UNITS_PROVIDER( pcbIUScale, EDA_UNITS::MILLIMETRES ), m_drcEngine( nullptr ) { } @@ -74,14 +71,15 @@ const wxString DRC_TEST_PROVIDER::GetDescription() const { return wxEmptyString; void DRC_TEST_PROVIDER::reportViolation( std::shared_ptr<DRC_ITEM>& item, - const VECTOR2I& aMarkerPos, int aMarkerLayer ) + const VECTOR2I& aMarkerPos, int aMarkerLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { std::lock_guard<std::mutex> lock( m_statsMutex ); if( item->GetViolatingRule() ) accountCheck( item->GetViolatingRule() ); item->SetViolatingTest( this ); - m_drcEngine->ReportViolation( item, aMarkerPos, aMarkerLayer ); + m_drcEngine->ReportViolation( item, aMarkerPos, aMarkerLayer, aCustomHandler ); } diff --git a/pcbnew/drc/drc_test_provider.h b/pcbnew/drc/drc_test_provider.h index e6500adf8f..f2769c833e 100644 --- a/pcbnew/drc/drc_test_provider.h +++ b/pcbnew/drc/drc_test_provider.h @@ -27,6 +27,7 @@ #include <board.h> #include <board_commit.h> +#include <drc/drc_engine.h> #include <pcb_marker.h> #include <functional> @@ -100,9 +101,6 @@ public: virtual const wxString GetName() const; virtual const wxString GetDescription() const; - BOARD_COMMIT* GetCommit() const { return m_commit; }; - void SetCommit( BOARD_COMMIT* aCommit ) { m_commit = aCommit; }; - protected: int forEachGeometryItem( const std::vector<KICAD_T>& aTypes, LSET aLayers, const std::function<bool(BOARD_ITEM*)>& aFunc ); @@ -113,7 +111,8 @@ protected: virtual void reportAux( const wxChar* fmt, ... ); virtual void reportViolation( std::shared_ptr<DRC_ITEM>& item, const VECTOR2I& aMarkerPos, - int aMarkerLayer ); + int aMarkerLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler = nullptr ); virtual bool reportProgress( size_t aCount, size_t aSize, size_t aDelta = 1 ); virtual bool reportPhase( const wxString& aStageName ); @@ -138,8 +137,7 @@ protected: DRC_ENGINE* m_drcEngine; std::unordered_map<const DRC_RULE*, int> m_stats; bool m_isRuleDriven = true; - std::mutex m_statsMutex; - BOARD_COMMIT* m_commit; + std::mutex m_statsMutex; }; #endif // DRC_TEST_PROVIDER__H diff --git a/pcbnew/drc/drc_test_provider_clearance_base.cpp b/pcbnew/drc/drc_test_provider_clearance_base.cpp index 219f5e3220..5d82723b91 100644 --- a/pcbnew/drc/drc_test_provider_clearance_base.cpp +++ b/pcbnew/drc/drc_test_provider_clearance_base.cpp @@ -25,9 +25,10 @@ #include <drc/drc_test_provider_clearance_base.h> -void DRC_TEST_PROVIDER_CLEARANCE_BASE::ShowPathDRC( const std::vector<PCB_SHAPE>& aShapes, - const VECTOR2I& aStart, const VECTOR2I& aEnd, - int aLength ) +DRC_CUSTOM_MARKER_HANDLER +DRC_TEST_PROVIDER_CLEARANCE_BASE::GetGraphicsHandler( const std::vector<PCB_SHAPE>& aShapes, + const VECTOR2I& aStart, const VECTOR2I& aEnd, + int aLength ) { COLOR_SETTINGS* colorSettings = new COLOR_SETTINGS( COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT ); COLOR_SETTINGS* defaultSettings = colorSettings->CreateBuiltinColorSettings()[0]; @@ -36,12 +37,6 @@ void DRC_TEST_PROVIDER_CLEARANCE_BASE::ShowPathDRC( const std::vector<PCB_SHAPE> std::vector<PCB_SHAPE> shortestPathShapes1, shortestPathShapes2; - // m_commit is protected and cannot be sent to the lambda function - BOARD_COMMIT* aCommit = m_commit; - - if( !m_commit ) - return; - // Add the path and its outlined area for( PCB_SHAPE sh : aShapes ) { @@ -82,17 +77,14 @@ void DRC_TEST_PROVIDER_CLEARANCE_BASE::ShowPathDRC( const std::vector<PCB_SHAPE> shortestPathShapes1.push_back( s2 ); } - m_GraphicsHandlerBuffer = - [aCommit, shortestPathShapes1, shortestPathShapes2]( PCB_MARKER* aMarker ) + return [shortestPathShapes1, shortestPathShapes2]( PCB_MARKER* aMarker ) { - if( !aCommit || !aMarker ) + if( !aMarker ) return; aMarker->SetShapes1( std::move( shortestPathShapes1 ) ); aMarker->SetShapes2( std::move( shortestPathShapes2 ) ); }; - - std::swap( m_GraphicsHandlerBuffer, m_drcEngine->m_graphicsHandler ); } @@ -128,10 +120,9 @@ void DRC_TEST_PROVIDER_CLEARANCE_BASE::ReportAndShowPathCuToCu( if( minGc ) { PATH_CONNECTION pc = minGc->m_path; - ShowPathDRC( minGc->GetShapes(), pc.a1, pc.a2, aDistance ); - reportViolation( aDrce, aMarkerPos, aMarkerLayer ); - // After a ShowPathDRC() call, restore the handler - std::swap( m_GraphicsHandlerBuffer, m_drcEngine->m_graphicsHandler ); + DRC_CUSTOM_MARKER_HANDLER handler = + GetGraphicsHandler( minGc->GetShapes(), pc.a1, pc.a2, aDistance ); + reportViolation( aDrce, aMarkerPos, aMarkerLayer, &handler ); } else { diff --git a/pcbnew/drc/drc_test_provider_clearance_base.h b/pcbnew/drc/drc_test_provider_clearance_base.h index ed60b9ad96..f766d8efb6 100644 --- a/pcbnew/drc/drc_test_provider_clearance_base.h +++ b/pcbnew/drc/drc_test_provider_clearance_base.h @@ -58,11 +58,9 @@ protected: int aMarkerLayer, const BOARD_ITEM* aItem1, const BOARD_ITEM* aItem2, PCB_LAYER_ID layer, int aDistance ); - void ShowPathDRC( const std::vector<PCB_SHAPE>& aShapes, const VECTOR2I& aStart, - const VECTOR2I& aEnd, int aLength ); - - - DRC_GRAPHICS_HANDLER m_GraphicsHandlerBuffer; + DRC_CUSTOM_MARKER_HANDLER GetGraphicsHandler( const std::vector<PCB_SHAPE>& aShapes, + const VECTOR2I& aStart, const VECTOR2I& aEnd, + int aLength ); }; diff --git a/pcbnew/drc/drc_test_provider_creepage.cpp b/pcbnew/drc/drc_test_provider_creepage.cpp index 1bae21fcc8..ba67d02910 100644 --- a/pcbnew/drc/drc_test_provider_creepage.cpp +++ b/pcbnew/drc/drc_test_provider_creepage.cpp @@ -217,10 +217,9 @@ int DRC_TEST_PROVIDER_CREEPAGE::testCreepage( CreepageGraph& aGraph, int aNetCod } } - this->ShowPathDRC( path, startPoint, endPoint, distance ); - reportViolation( drce, shortestPath[1]->m_path.a2, aLayer ); - // After a ShowPathDRC() call, restore the handler - std::swap( m_GraphicsHandlerBuffer, m_drcEngine->m_graphicsHandler ); + DRC_CUSTOM_MARKER_HANDLER graphicsHandler = + GetGraphicsHandler( path, startPoint, endPoint, distance ); + reportViolation( drce, shortestPath[1]->m_path.a2, aLayer, &graphicsHandler ); } shortestPath.clear(); diff --git a/pcbnew/pcbnew_jobs_handler.cpp b/pcbnew/pcbnew_jobs_handler.cpp index ab77291e47..6ca227848f 100644 --- a/pcbnew/pcbnew_jobs_handler.cpp +++ b/pcbnew/pcbnew_jobs_handler.cpp @@ -1641,7 +1641,8 @@ int PCBNEW_JOBS_HANDLER::JobExportDrc( JOB* aJob ) drcEngine->SetProgressReporter( nullptr ); drcEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { PCB_MARKER* marker = new PCB_MARKER( aItem, aPos, aLayer ); commit.Add( marker ); diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index fb025601ca..7d4e4b153b 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -609,7 +609,8 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, engine->SetProgressReporter( nullptr ); engine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2D aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2D aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( aItem->GetErrorCode() == DRCE_MISSING_FOOTPRINT || aItem->GetErrorCode() == DRCE_DUPLICATE_FOOTPRINT diff --git a/pcbnew/tools/drc_tool.cpp b/pcbnew/tools/drc_tool.cpp index cd56e67503..debc92632c 100644 --- a/pcbnew/tools/drc_tool.cpp +++ b/pcbnew/tools/drc_tool.cpp @@ -172,10 +172,14 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aRefillZones m_drcEngine->SetProgressReporter( aProgressReporter ); m_drcEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { PCB_MARKER* marker = new PCB_MARKER( aItem, aPos, aLayer ); - m_drcEngine->GraphicsHandler( marker ); + + if( aCustomHandler ) + ( *aCustomHandler )( marker ); + commit.Add( marker ); } ); diff --git a/qa/tests/pcbnew/drc/test_custom_rule_severities.cpp b/qa/tests/pcbnew/drc/test_custom_rule_severities.cpp index 4336f5876c..c3f64e760b 100644 --- a/qa/tests/pcbnew/drc/test_custom_rule_severities.cpp +++ b/qa/tests/pcbnew/drc/test_custom_rule_severities.cpp @@ -63,7 +63,8 @@ BOOST_FIXTURE_TEST_CASE( DRCCustomRuleSeverityTest, DRC_REGRESSION_TEST_FIXTURE bds.m_DRCSeverities[ DRCE_FOOTPRINT_TYPE_MISMATCH ] = SEVERITY::RPT_SEVERITY_IGNORE; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { PCB_MARKER temp( aItem, aPos ); diff --git a/qa/tests/pcbnew/drc/test_drc_component_classes.cpp b/qa/tests/pcbnew/drc/test_drc_component_classes.cpp index 2bc6e7e9bc..447ccc2f3a 100644 --- a/qa/tests/pcbnew/drc/test_drc_component_classes.cpp +++ b/qa/tests/pcbnew/drc/test_drc_component_classes.cpp @@ -74,7 +74,8 @@ BOOST_FIXTURE_TEST_CASE( DRCComponentClasses, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCSeverities[ DRCE_ASSERTION_FAILURE ] = SEVERITY::RPT_SEVERITY_ERROR; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_copper_conn.cpp b/qa/tests/pcbnew/drc/test_drc_copper_conn.cpp index 1375b1c829..355a7caa38 100644 --- a/qa/tests/pcbnew/drc/test_drc_copper_conn.cpp +++ b/qa/tests/pcbnew/drc/test_drc_copper_conn.cpp @@ -80,7 +80,8 @@ BOOST_FIXTURE_TEST_CASE( DRCCopperConn, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCSeverities[ DRCE_CONNECTION_WIDTH ] = SEVERITY::RPT_SEVERITY_ERROR; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_copper_graphics.cpp b/qa/tests/pcbnew/drc/test_drc_copper_graphics.cpp index 8a868d44fd..03539a05e4 100644 --- a/qa/tests/pcbnew/drc/test_drc_copper_graphics.cpp +++ b/qa/tests/pcbnew/drc/test_drc_copper_graphics.cpp @@ -63,7 +63,8 @@ BOOST_FIXTURE_TEST_CASE( DRCCopperGraphicsTest, DRC_COPPER_GRAPHICS_TEST_FIXTURE bds.m_DRCSeverities[ DRCE_NONMIRRORED_TEXT_ON_BACK_LAYER ] = SEVERITY::RPT_SEVERITY_IGNORE; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { PCB_MARKER temp( aItem, aPos ); diff --git a/qa/tests/pcbnew/drc/test_drc_copper_sliver.cpp b/qa/tests/pcbnew/drc/test_drc_copper_sliver.cpp index c8cd9247ca..45f2f3c96d 100644 --- a/qa/tests/pcbnew/drc/test_drc_copper_sliver.cpp +++ b/qa/tests/pcbnew/drc/test_drc_copper_sliver.cpp @@ -73,7 +73,8 @@ BOOST_FIXTURE_TEST_CASE( DRCCopperSliver, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCSeverities[ DRCE_COPPER_SLIVER ] = SEVERITY::RPT_SEVERITY_ERROR; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_courtyard_invalid.cpp b/qa/tests/pcbnew/drc/test_drc_courtyard_invalid.cpp index 1bd98993e5..d4b8605700 100644 --- a/qa/tests/pcbnew/drc/test_drc_courtyard_invalid.cpp +++ b/qa/tests/pcbnew/drc/test_drc_courtyard_invalid.cpp @@ -304,7 +304,8 @@ void DoCourtyardInvalidTest( const COURTYARD_INVALID_CASE& aCase, drcEngine.InitEngine( wxFileName() ); drcEngine.SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( aItem->GetErrorCode() == DRCE_OVERLAPPING_FOOTPRINTS || aItem->GetErrorCode() == DRCE_MALFORMED_COURTYARD diff --git a/qa/tests/pcbnew/drc/test_drc_courtyard_overlap.cpp b/qa/tests/pcbnew/drc/test_drc_courtyard_overlap.cpp index c3278224bb..5b227f2637 100644 --- a/qa/tests/pcbnew/drc/test_drc_courtyard_overlap.cpp +++ b/qa/tests/pcbnew/drc/test_drc_courtyard_overlap.cpp @@ -460,7 +460,8 @@ static void DoCourtyardOverlapTest( const COURTYARD_OVERLAP_TEST_CASE& aCase, drcEngine.InitEngine( wxFileName() ); drcEngine.SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( aItem->GetErrorCode() == DRCE_OVERLAPPING_FOOTPRINTS || aItem->GetErrorCode() == DRCE_MALFORMED_COURTYARD diff --git a/qa/tests/pcbnew/drc/test_drc_incorrect_text_mirror.cpp b/qa/tests/pcbnew/drc/test_drc_incorrect_text_mirror.cpp index 96ff1330d7..54ff67382c 100644 --- a/qa/tests/pcbnew/drc/test_drc_incorrect_text_mirror.cpp +++ b/qa/tests/pcbnew/drc/test_drc_incorrect_text_mirror.cpp @@ -62,7 +62,8 @@ BOOST_FIXTURE_TEST_CASE( DRCIncorrectTextMirror, DRC_INCORRECT_TEXT_MIRROR_TEST_ bds.m_DRCSeverities[DRCE_NONMIRRORED_TEXT_ON_BACK_LAYER] = SEVERITY::RPT_SEVERITY_ERROR; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_multi_netclasses.cpp b/qa/tests/pcbnew/drc/test_drc_multi_netclasses.cpp index b8d0c6c81b..9160d80974 100644 --- a/qa/tests/pcbnew/drc/test_drc_multi_netclasses.cpp +++ b/qa/tests/pcbnew/drc/test_drc_multi_netclasses.cpp @@ -77,7 +77,8 @@ BOOST_FIXTURE_TEST_CASE( DRCMultiNetclasses, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCSeverities[ DRCE_TRACK_WIDTH ] = SEVERITY::RPT_SEVERITY_ERROR; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_regressions.cpp b/qa/tests/pcbnew/drc/test_drc_regressions.cpp index 9502c69309..6ca662caa9 100644 --- a/qa/tests/pcbnew/drc/test_drc_regressions.cpp +++ b/qa/tests/pcbnew/drc/test_drc_regressions.cpp @@ -87,7 +87,8 @@ BOOST_FIXTURE_TEST_CASE( DRCFalsePositiveRegressions, DRC_REGRESSION_TEST_FIXTUR bds.m_DRCSeverities[ DRCE_LIB_FOOTPRINT_MISMATCH ] = SEVERITY::RPT_SEVERITY_IGNORE; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); @@ -173,7 +174,8 @@ BOOST_FIXTURE_TEST_CASE( DRCFalseNegativeRegressions, DRC_REGRESSION_TEST_FIXTUR bds.m_DRCSeverities[test] = severity; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { markers.emplace_back( PCB_MARKER( aItem, aPos ) ); diff --git a/qa/tests/pcbnew/drc/test_drc_skew.cpp b/qa/tests/pcbnew/drc/test_drc_skew.cpp index 441078bfa1..749e6775ed 100644 --- a/qa/tests/pcbnew/drc/test_drc_skew.cpp +++ b/qa/tests/pcbnew/drc/test_drc_skew.cpp @@ -78,7 +78,8 @@ BOOST_FIXTURE_TEST_CASE( DRCSkew, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCSeverities[ DRCE_SKEW_OUT_OF_RANGE ] = SEVERITY::RPT_SEVERITY_ERROR; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_solder_mask_bridging.cpp b/qa/tests/pcbnew/drc/test_solder_mask_bridging.cpp index c12d8b7315..7193566c3e 100644 --- a/qa/tests/pcbnew/drc/test_solder_mask_bridging.cpp +++ b/qa/tests/pcbnew/drc/test_solder_mask_bridging.cpp @@ -58,7 +58,8 @@ BOOST_FIXTURE_TEST_CASE( DRCSolderMaskBridgingTest, DRC_SOLDER_MASK_BRIDGING_TES bds.m_DRCSeverities[ DRCE_SILK_CLEARANCE ] = SEVERITY::RPT_SEVERITY_IGNORE; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { PCB_MARKER temp( aItem, aPos ); diff --git a/qa/tests/pcbnew/test_tracks_cleaner.cpp b/qa/tests/pcbnew/test_tracks_cleaner.cpp index 43db438a3b..f42e983bf4 100644 --- a/qa/tests/pcbnew/test_tracks_cleaner.cpp +++ b/qa/tests/pcbnew/test_tracks_cleaner.cpp @@ -192,7 +192,8 @@ BOOST_FIXTURE_TEST_CASE( TrackCleanerRegressionTests, TRACK_CLEANER_TEST_FIXTURE bds.m_DRCSeverities[ DRCE_SOLDERMASK_BRIDGE ] = SEVERITY::RPT_SEVERITY_IGNORE; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( aItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/test_zone_filler.cpp b/qa/tests/pcbnew/test_zone_filler.cpp index 5db44a81a8..c002a604af 100644 --- a/qa/tests/pcbnew/test_zone_filler.cpp +++ b/qa/tests/pcbnew/test_zone_filler.cpp @@ -101,7 +101,8 @@ BOOST_FIXTURE_TEST_CASE( BasicZoneFills, ZONE_FILL_TEST_FIXTURE ) bds.m_DRCEngine->InitEngine( wxFileName() ); // Just to be sure to be sure bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( aItem->GetErrorCode() == DRCE_CLEARANCE ) { @@ -124,6 +125,7 @@ BOOST_FIXTURE_TEST_CASE( BasicZoneFills, ZONE_FILL_TEST_FIXTURE ) else if( trk_b && trk_b->m_Uuid == arc8 ) foundArc8Error = true; else if( trk_b && trk_b->m_Uuid == arc12 ) foundArc12Error = true; else foundOtherError = true; + } } ); @@ -194,7 +196,8 @@ BOOST_FIXTURE_TEST_CASE( RegressionZoneFillTests, ZONE_FILL_TEST_FIXTURE ) std::vector<DRC_ITEM> violations; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( aItem->GetErrorCode() == DRCE_CLEARANCE ) violations.push_back( *aItem ); @@ -242,7 +245,8 @@ BOOST_FIXTURE_TEST_CASE( RegressionSliverZoneFillTests, ZONE_FILL_TEST_FIXTURE ) std::vector<DRC_ITEM> violations; bds.m_DRCEngine->SetViolationHandler( - [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer ) + [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer, + DRC_CUSTOM_MARKER_HANDLER* aCustomHandler ) { if( aItem->GetErrorCode() == DRCE_COPPER_SLIVER ) violations.push_back( *aItem );