7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-14 12:59:34 +00:00

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
This commit is contained in:
JamesJCode 2024-12-23 15:29:29 +00:00
parent 1fe2dcc914
commit 3800bae281
24 changed files with 76 additions and 93 deletions

View File

@ -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 )

View File

@ -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;

View File

@ -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 );
}

View File

@ -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

View File

@ -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
{

View File

@ -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 );
};

View File

@ -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();

View File

@ -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 );

View File

@ -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

View File

@ -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 );
} );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -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

View File

@ -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

View File

@ -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 );

View File

@ -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 );

View File

@ -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 ) );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );