Migrate RC_ITEM to use shared_ptr

This commit is contained in:
Tomasz Wlostowski 2020-08-11 15:33:16 +02:00
parent 2b6ef6964a
commit d937fadd6f
49 changed files with 294 additions and 302 deletions

View File

@ -59,7 +59,7 @@ static const VECTOR2I MarkerShapeCorners[] =
const unsigned CORNERS_COUNT = arrayDim( MarkerShapeCorners );
MARKER_BASE::MARKER_BASE( int aScalingFactor, RC_ITEM* aItem, TYPEMARKER aType ) :
MARKER_BASE::MARKER_BASE( int aScalingFactor, std::shared_ptr<RC_ITEM> aItem, TYPEMARKER aType ) :
m_markerType( aType ),
m_excluded( false ),
m_rcItem( aItem ),
@ -85,8 +85,6 @@ MARKER_BASE::MARKER_BASE( int aScalingFactor, RC_ITEM* aItem, TYPEMARKER aType )
MARKER_BASE::~MARKER_BASE()
{
printf("del rcitem %p\n", m_rcItem );
delete m_rcItem;
}

View File

@ -94,7 +94,7 @@ KIID RC_TREE_MODEL::ToUUID( wxDataViewItem aItem )
if( node )
{
const RC_ITEM* rc_item = node->m_RcItem;
const std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
switch( node->m_Type )
{
@ -142,7 +142,7 @@ void RC_TREE_MODEL::rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities
{
wxWindowUpdateLocker updateLock( m_view );
RC_ITEM* selectedRcItem = nullptr;
std::shared_ptr<RC_ITEM> selectedRcItem = nullptr;
if( m_view )
{
@ -170,7 +170,7 @@ void RC_TREE_MODEL::rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities
for( int i = 0; m_rcItemsProvider && i < m_rcItemsProvider->GetCount(); ++i )
{
RC_ITEM* rcItem = m_rcItemsProvider->GetItem( i );
std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
m_tree.push_back( new RC_TREE_NODE( nullptr, rcItem, RC_TREE_NODE::MARKER ) );
RC_TREE_NODE* n = m_tree.back();
@ -279,7 +279,7 @@ void RC_TREE_MODEL::GetValue( wxVariant& aVariant,
unsigned int aCol ) const
{
const RC_TREE_NODE* node = ToNode( aItem );
const RC_ITEM* rcItem = node->m_RcItem;
const std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
switch( node->m_Type )
{
@ -394,7 +394,7 @@ void RC_TREE_MODEL::DeleteCurrentItem( bool aDeep )
void RC_TREE_MODEL::DeleteItems( bool aCurrentOnly, bool aIncludeExclusions, bool aDeep )
{
RC_TREE_NODE* current_node = ToNode( m_view->GetCurrentItem() );
const RC_ITEM* current_item = current_node ? current_node->m_RcItem : nullptr;
const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->m_RcItem : nullptr;
if( aCurrentOnly && !current_item )
{
@ -404,7 +404,7 @@ void RC_TREE_MODEL::DeleteItems( bool aCurrentOnly, bool aIncludeExclusions, boo
for( int i = m_rcItemsProvider->GetCount() - 1; i >= 0; --i )
{
RC_ITEM* rcItem = m_rcItemsProvider->GetItem( i );
std::shared_ptr<RC_ITEM> rcItem = m_rcItemsProvider->GetItem( i );
MARKER_BASE* marker = rcItem->GetParent();
bool excluded = marker ? marker->IsExcluded() : false;

View File

@ -50,7 +50,7 @@ public:
* Function GetItem
* retrieves a RC_ITEM by index.
*/
virtual RC_ITEM* GetItem( int aIndex ) = 0;
virtual std::shared_ptr<RC_ITEM> GetItem( int aIndex ) = 0;
/**
* Function DeleteItem
@ -95,7 +95,7 @@ public:
{
}
RC_ITEM( RC_ITEM* aItem )
RC_ITEM( std::shared_ptr<RC_ITEM> aItem )
{
m_errorCode = aItem->m_errorCode;
m_errorMessage = aItem->m_errorMessage;
@ -185,7 +185,7 @@ class RC_TREE_NODE
public:
enum NODE_TYPE { MARKER, MAIN_ITEM, AUX_ITEM, AUX_ITEM2, AUX_ITEM3 };
RC_TREE_NODE( RC_TREE_NODE* aParent, RC_ITEM* aRcItem, NODE_TYPE aType ) :
RC_TREE_NODE( RC_TREE_NODE* aParent, std::shared_ptr<RC_ITEM> aRcItem, NODE_TYPE aType ) :
m_Type( aType ),
m_RcItem( aRcItem ),
m_Parent( aParent )
@ -198,7 +198,7 @@ public:
}
NODE_TYPE m_Type;
RC_ITEM* m_RcItem;
std::shared_ptr<RC_ITEM> m_RcItem;
RC_TREE_NODE* m_Parent;
std::vector<RC_TREE_NODE*> m_Children;

View File

@ -172,7 +172,7 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCreateMarkers )
static_cast<SCH_PIN*>( candidates[0] )->GetTransformedPosition() :
candidates[0]->GetPosition();
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_DRIVER_CONFLICT );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DRIVER_CONFLICT );
ercItem->SetItems( candidates[0], second_item );
SCH_MARKER* marker = new SCH_MARKER( ercItem, pos );
@ -2118,7 +2118,7 @@ bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSu
if( net_item && bus_item )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_BUS_TO_NET_CONFLICT );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_BUS_TO_NET_CONFLICT );
ercItem->SetItems( net_item, bus_item );
SCH_MARKER* marker = new SCH_MARKER( ercItem, net_item->GetPosition() );
@ -2186,7 +2186,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusConflicts( const CONNECTION_SUBGRAPH* aSu
if( !match )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_BUS_TO_BUS_CONFLICT );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_BUS_TO_BUS_CONFLICT );
ercItem->SetItems( label, port );
SCH_MARKER* marker = new SCH_MARKER( ercItem, label->GetPosition() );
@ -2266,7 +2266,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts( const CONNECTION_SUBGRAPH
if( conflict )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_CONFLICT );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_CONFLICT );
ercItem->SetItems( bus_entry, bus_wire );
SCH_MARKER* marker = new SCH_MARKER( ercItem, bus_entry->GetPosition() );
@ -2319,7 +2319,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
if( pin && has_invalid_items )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
ercItem->SetItems( pin );
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetTransformedPosition() );
@ -2330,7 +2330,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
if( !has_other_items )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_NOT_CONNECTED );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_NOT_CONNECTED );
ercItem->SetItems( aSubgraph->m_no_connect );
SCH_MARKER* marker = new SCH_MARKER( ercItem, aSubgraph->m_no_connect->GetPosition() );
@ -2385,7 +2385,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
if( pin && !has_other_connections && pin->GetType() != ELECTRICAL_PINTYPE::PT_NC )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_PIN_NOT_CONNECTED );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_PIN_NOT_CONNECTED );
ercItem->SetItems( pin );
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetTransformedPosition() );
@ -2479,7 +2479,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
if( !has_other_connections )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( is_global ? ERCE_GLOBLABEL : ERCE_LABEL_NOT_CONNECTED );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( is_global ? ERCE_GLOBLABEL : ERCE_LABEL_NOT_CONNECTED );
ercItem->SetItems( text );
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );

View File

@ -315,7 +315,7 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter )
pin_to_net_map[pin_name],
item->GetNetName() );
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_NET );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_NET );
ercItem->SetErrorMessage( msg );
ercItem->SetItems( item->m_Comp );
@ -419,7 +419,7 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
ERC_SETTINGS& settings = m_parent->Schematic().ErcSettings();
RC_ITEM* rcItem = node->m_RcItem;
std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
wxString listName;
wxMenu menu;
wxString msg;

View File

@ -51,7 +51,7 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
m_pinToPinError = ERC_ITEM::Create( ERCE_PIN_TO_PIN_WARNING );
m_severities = new PANEL_SETUP_SEVERITIES( this, ERC_ITEM::GetItemsWithSeverities(),
schematic.ErcSettings().m_Severities,
m_pinToPinError );
m_pinToPinError.get() );
m_textVars = new PANEL_TEXT_VARIABLES( m_treebook, &Prj() );
@ -87,8 +87,6 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
DIALOG_SCHEMATIC_SETUP::~DIALOG_SCHEMATIC_SETUP()
{
delete m_pinToPinError;
m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
wxBookCtrlEventHandler( DIALOG_SCHEMATIC_SETUP::OnPageChange ), NULL, this );
}

View File

@ -50,7 +50,7 @@ protected:
PANEL_SETUP_SEVERITIES* m_severities;
PANEL_SETUP_NETCLASSES* m_netclasses;
PANEL_TEXT_VARIABLES* m_textVars;
ERC_ITEM* m_pinToPinError;
std::shared_ptr<ERC_ITEM> m_pinToPinError;
std::vector<bool> m_macHack;

View File

@ -127,7 +127,7 @@ int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker )
{
if( aCreateMarker )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_DUPLICATE_SHEET_NAME );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DUPLICATE_SHEET_NAME );
ercItem->SetItems( sheet, test_item );
SCH_MARKER* marker = new SCH_MARKER( ercItem, sheet->GetPosition() );
@ -178,7 +178,7 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
pos = component->GetTransform().TransformCoordinate( pos );
pos += component->GetPosition();
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
ercItem->SetItems( &field );
SCH_MARKER* marker = new SCH_MARKER( ercItem, pos );
@ -194,7 +194,7 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
{
if( unresolved( field.GetShownText() ) )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
ercItem->SetItems( &field );
SCH_MARKER* marker = new SCH_MARKER( ercItem, field.GetPosition() );
@ -206,7 +206,7 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
{
if( pin->GetShownText().Matches( wxT( "*${*}*" ) ) )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
ercItem->SetItems( pin );
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
@ -218,7 +218,7 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
{
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
ercItem->SetItems( text );
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
@ -233,7 +233,7 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
{
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
ercItem->SetErrorMessage( _( "Unresolved text variable in worksheet." ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
@ -268,7 +268,7 @@ int ERC_TESTER::TestConflictingBusAliases()
alias->GetParent()->GetFileName(),
test->GetParent()->GetFileName() );
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_BUS_ALIAS_CONFLICT );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_BUS_ALIAS_CONFLICT );
ercItem->SetErrorMessage( msg );
SCH_MARKER* marker = new SCH_MARKER( ercItem, wxPoint() );
@ -336,7 +336,7 @@ int ERC_TESTER::TestMultiunitFootprints()
msg.Printf( _( "Different footprints assigned to %s and %s" ),
unitName, secondName );
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_FP );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_FP );
ercItem->SetErrorMessage( msg );
ercItem->SetItems( unit, secondUnit );
@ -368,7 +368,7 @@ void ERC_TESTER::diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItem
{
if( settings.GetSeverity( ERCE_PIN_NOT_DRIVEN ) != RPT_SEVERITY_IGNORE )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_PIN_NOT_DRIVEN );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_PIN_NOT_DRIVEN );
ercItem->SetItems( pin );
SCH_MARKER* marker = new SCH_MARKER( ercItem, aNetItemRef->m_Start );
@ -382,7 +382,7 @@ void ERC_TESTER::diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItem
{
if( settings.GetSeverity( ERCE_PIN_TO_PIN_WARNING ) != RPT_SEVERITY_IGNORE )
{
ERC_ITEM* ercItem = ERC_ITEM::Create(
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create(
aDiag == PIN_ERROR::PP_ERROR ? ERCE_PIN_TO_PIN_ERROR : ERCE_PIN_TO_PIN_WARNING );
ercItem->SetItems( pin, static_cast<SCH_PIN*>( aNetItemTst->m_Comp ) );
@ -557,7 +557,7 @@ int ERC_TESTER::TestNoConnectPins()
{
err_count++;
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
ercItem->SetItems( pair.second[0], pair.second[1],
pair.second.size() > 2 ? pair.second[2] : nullptr,
@ -763,7 +763,7 @@ static int countIndenticalLabels( std::vector<NETLIST_OBJECT*>& aList, NETLIST_O
// Helper function: creates a marker for similar labels ERC warning
static void SimilarLabelsDiagnose( NETLIST_OBJECT* aItemA, NETLIST_OBJECT* aItemB )
{
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS );
ercItem->SetItems( aItemA->m_Comp, aItemB->m_Comp );
SCH_MARKER* marker = new SCH_MARKER( ercItem, aItemA->m_Start );

View File

@ -141,73 +141,76 @@ std::vector<std::reference_wrapper<RC_ITEM>> ERC_ITEM::allItemTypes( {
ERC_ITEM* ERC_ITEM::Create( int aErrorCode )
std::shared_ptr<ERC_ITEM> ERC_ITEM::Create( int aErrorCode )
{
ERC_ITEM *item;
switch( aErrorCode )
{
case ERCE_DUPLICATE_SHEET_NAME:
return new ERC_ITEM( duplicateSheetName );
item = new ERC_ITEM( duplicateSheetName ); break;
case ERCE_PIN_NOT_CONNECTED:
return new ERC_ITEM( pinNotConnected );
item = new ERC_ITEM( pinNotConnected ); break;
case ERCE_PIN_NOT_DRIVEN:
return new ERC_ITEM( pinNotDriven );
item = new ERC_ITEM( pinNotDriven ); break;
case ERCE_PIN_TO_PIN_WARNING:
return new ERC_ITEM( pinTableWarning );
item = new ERC_ITEM( pinTableWarning ); break;
case ERCE_PIN_TO_PIN_ERROR:
return new ERC_ITEM( pinTableError );
item = new ERC_ITEM( pinTableError ); break;
case ERCE_HIERACHICAL_LABEL:
return new ERC_ITEM( hierLabelMismatch );
item = new ERC_ITEM( hierLabelMismatch ); break;
case ERCE_NOCONNECT_CONNECTED:
return new ERC_ITEM( noConnectConnected );
item = new ERC_ITEM( noConnectConnected ); break;
case ERCE_NOCONNECT_NOT_CONNECTED:
return new ERC_ITEM( noConnectDangling );
item = new ERC_ITEM( noConnectDangling ); break;
case ERCE_LABEL_NOT_CONNECTED:
return new ERC_ITEM( labelDangling );
item = new ERC_ITEM( labelDangling ); break;
case ERCE_SIMILAR_LABELS:
return new ERC_ITEM( similarLabels );
item = new ERC_ITEM( similarLabels ); break;
case ERCE_DIFFERENT_UNIT_FP:
return new ERC_ITEM( differentUnitFootprint );
item = new ERC_ITEM( differentUnitFootprint ); break;
case ERCE_DIFFERENT_UNIT_NET:
return new ERC_ITEM( differentUnitNet );
item = new ERC_ITEM( differentUnitNet ); break;
case ERCE_BUS_ALIAS_CONFLICT:
return new ERC_ITEM( busDefinitionConflict );
item = new ERC_ITEM( busDefinitionConflict ); break;
case ERCE_DRIVER_CONFLICT:
return new ERC_ITEM( multipleNetNames );
item = new ERC_ITEM( multipleNetNames ); break;
case ERCE_BUS_ENTRY_CONFLICT:
return new ERC_ITEM( netNotBusMember );
item = new ERC_ITEM( netNotBusMember ); break;
case ERCE_BUS_LABEL_ERROR:
return new ERC_ITEM( busLabelSyntax );
item = new ERC_ITEM( busLabelSyntax ); break;
case ERCE_BUS_TO_BUS_CONFLICT:
return new ERC_ITEM( busToBusConflict );
item = new ERC_ITEM( busToBusConflict ); break;
case ERCE_BUS_TO_NET_CONFLICT:
return new ERC_ITEM( busToNetConflict );
item = new ERC_ITEM( busToNetConflict ); break;
case ERCE_GLOBLABEL:
return new ERC_ITEM( globalLabelDangling );
item = new ERC_ITEM( globalLabelDangling ); break;
case ERCE_UNRESOLVED_VARIABLE:
return new ERC_ITEM( unresolvedVariable );
item = new ERC_ITEM( unresolvedVariable ); break;
case ERCE_UNSPECIFIED:
default:
wxFAIL_MSG( "Unknown ERC error code" );
return nullptr;
}
return std::shared_ptr<ERC_ITEM>( item );
}

View File

@ -34,7 +34,7 @@ public:
* Constructs an ERC_ITEM for the given error code
* @see ERCE_T
*/
static ERC_ITEM* Create( int aErrorCode );
static std::shared_ptr<ERC_ITEM> Create( int aErrorCode );
static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
{

View File

@ -296,11 +296,17 @@ int SHEETLIST_ERC_ITEMS_PROVIDER::GetCount( int aSeverity )
}
ERC_ITEM* SHEETLIST_ERC_ITEMS_PROVIDER::GetItem( int aIndex )
std::shared_ptr<ERC_ITEM> SHEETLIST_ERC_ITEMS_PROVIDER::GetERCItem( int aIndex )
{
SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
return marker ? static_cast<ERC_ITEM*>( marker->GetRCItem() ) : nullptr;
return marker ? std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() ) : nullptr;
}
std::shared_ptr<RC_ITEM> SHEETLIST_ERC_ITEMS_PROVIDER::GetItem( int aIndex )
{
return GetERCItem( aIndex );
}

View File

@ -187,7 +187,9 @@ public:
int GetCount( int aSeverity = -1 ) override;
ERC_ITEM* GetItem( int aIndex ) override;
std::shared_ptr<RC_ITEM> GetItem( int aIndex ) override;
std::shared_ptr<ERC_ITEM> GetERCItem( int aIndex );
void DeleteItem( int aIndex, bool aDeep ) override;

View File

@ -2047,7 +2047,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
}
else
{
ERC_ITEM* ercItem = ERC_ITEM::Create( 0 );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, linestart );
@ -2085,7 +2085,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
}
else
{
ERC_ITEM* ercItem = ERC_ITEM::Create( 0 );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, linestart );
@ -2127,7 +2127,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
}
else
{
ERC_ITEM* ercItem = ERC_ITEM::Create( 0 );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, lineend );
@ -2164,7 +2164,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
}
else
{
ERC_ITEM* ercItem = ERC_ITEM::Create( 0 );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, lineend );
@ -2206,7 +2206,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
}
else
{
ERC_ITEM* ercItem = ERC_ITEM::Create( 0 );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, linestart );
@ -2238,7 +2238,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
}
else
{
ERC_ITEM* ercItem = ERC_ITEM::Create( 0 );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, linestart );
@ -2277,7 +2277,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
}
else
{
ERC_ITEM* ercItem = ERC_ITEM::Create( 0 );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, lineend );
@ -2309,7 +2309,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
}
else
{
ERC_ITEM* ercItem = ERC_ITEM::Create( 0 );
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, lineend );

View File

@ -41,7 +41,7 @@
#define SCALING_FACTOR Millimeter2iu( 0.15 )
SCH_MARKER::SCH_MARKER( ERC_ITEM* aItem, const wxPoint& aPos ) :
SCH_MARKER::SCH_MARKER( std::shared_ptr<ERC_ITEM> aItem, const wxPoint& aPos ) :
SCH_ITEM( nullptr, SCH_MARKER_T ),
MARKER_BASE( SCALING_FACTOR, aItem, MARKER_BASE::MARKER_ERC )
{

View File

@ -33,7 +33,7 @@
class SCH_MARKER : public SCH_ITEM, public MARKER_BASE
{
public:
SCH_MARKER( ERC_ITEM* aItem, const wxPoint& aPos );
SCH_MARKER( std::shared_ptr<ERC_ITEM> aItem, const wxPoint& aPos );
// Do not create a copy constructor. The one generated by the compiler is adequate.

View File

@ -1346,7 +1346,7 @@ void SCH_SCREENS::DeleteMarkers( enum MARKER_BASE::TYPEMARKER aMarkerType, int a
for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
{
SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
RC_ITEM* rcItem = marker->GetRCItem();
std::shared_ptr<RC_ITEM>rcItem = marker->GetRCItem();
if( marker->GetMarkerType() == aMarkerType
&& ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode )

View File

@ -26,6 +26,8 @@
#ifndef MARKER_BASE_H
#define MARKER_BASE_H
#include <memory>
#include <rc_item.h>
#include <gr_basic.h>
#include <eda_rect.h>
@ -61,7 +63,7 @@ public:
protected:
TYPEMARKER m_markerType; // The type of marker (useful to filter markers)
bool m_excluded; // User has excluded this specific error
RC_ITEM* m_rcItem;
std::shared_ptr<RC_ITEM> m_rcItem;
int m_scalingFactor; // Scaling factor to convert corners coordinates
// to internat units coordinates
@ -71,8 +73,7 @@ protected:
public:
MARKER_BASE( int aScalingFactor, RC_ITEM* aItem, TYPEMARKER aType = MARKER_UNSPEC );
MARKER_BASE( int aScalingFactor, std::shared_ptr<RC_ITEM> aItem, TYPEMARKER aType = MARKER_UNSPEC );
virtual ~MARKER_BASE();
/** The scaling factor to convert polygonal shape coordinates to internal units
@ -114,8 +115,9 @@ public:
* interface may be used.
* @return const& DRC_ITEM
*/
RC_ITEM* GetRCItem() { return m_rcItem; }
const RC_ITEM* GetRCItem() const { return m_rcItem; }
// fixme: use shared_ptr
std::shared_ptr<RC_ITEM> GetRCItem() const { return m_rcItem; }
/**
* Tests if the given wxPoint is within the bounds of this object.

View File

@ -677,9 +677,8 @@ bool BOARD_DESIGN_SETTINGS::LoadFromFile( const wxString& aDirectory )
auto drcName =
[]( int aCode ) -> std::string
{
DRC_ITEM* item = DRC_ITEM::Create( aCode );
std::shared_ptr<DRC_ITEM> item = DRC_ITEM::Create( aCode );
wxString name = item->GetSettingsKey();
delete item;
return std::string( name.ToUTF8() );
};

View File

@ -42,7 +42,8 @@
#define SCALING_FACTOR Millimeter2iu( 0.1 )
MARKER_PCB::MARKER_PCB( DRC_ITEM* aItem, const wxPoint& aPosition ) :
MARKER_PCB::MARKER_PCB( std::shared_ptr<RC_ITEM> aItem, const wxPoint& aPosition ) :
BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add()
MARKER_BASE( SCALING_FACTOR, aItem )
{
@ -76,7 +77,7 @@ MARKER_PCB* MARKER_PCB::Deserialize( const wxString& data )
wxPoint markerPos( (int) strtol( props[1].c_str(), nullptr, 10 ),
(int) strtol( props[2].c_str(), nullptr, 10 ) );
DRC_ITEM* drcItem = DRC_ITEM::Create( props[0] );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( props[0] );
if( !drcItem )
return nullptr;

View File

@ -46,8 +46,7 @@ class MSG_PANEL_ITEM;
class MARKER_PCB : public BOARD_ITEM, public MARKER_BASE
{
public:
MARKER_PCB( DRC_ITEM* aItem, const wxPoint& aPosition );
MARKER_PCB( std::shared_ptr<RC_ITEM> aItem, const wxPoint& aPosition );
~MARKER_PCB();
static inline bool ClassOf( const EDA_ITEM* aItem )

View File

@ -73,11 +73,11 @@ public:
*/
class VECTOR_CLEANUP_ITEMS_PROVIDER : public RC_ITEMS_PROVIDER
{
std::vector<CLEANUP_ITEM*>* m_sourceVector; // owns its CLEANUP_ITEMs
std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_sourceVector; // owns its CLEANUP_ITEMs
public:
VECTOR_CLEANUP_ITEMS_PROVIDER( std::vector<CLEANUP_ITEM*>* aList ) :
VECTOR_CLEANUP_ITEMS_PROVIDER( std::vector<std::shared_ptr<CLEANUP_ITEM> >* aList ) :
m_sourceVector( aList )
{
}
@ -91,18 +91,22 @@ public:
return m_sourceVector->size();
}
CLEANUP_ITEM* GetItem( int aIndex ) override
std::shared_ptr<RC_ITEM> GetItem( int aIndex ) override
{
return m_sourceVector->at( aIndex );
}
std::shared_ptr<CLEANUP_ITEM> GetCleanupItem( int aIndex )
{
return m_sourceVector->at( aIndex );
}
void DeleteItem( int aIndex, bool aDeep ) override
{
if( aDeep )
{
CLEANUP_ITEM* item = m_sourceVector->at( aIndex );
delete item;
auto item = m_sourceVector->at( aIndex );
m_sourceVector->erase( m_sourceVector->begin() + aIndex );
}
}
@ -111,9 +115,6 @@ public:
{
if( aDeep )
{
for( CLEANUP_ITEM* item : *m_sourceVector )
delete item;
m_sourceVector->clear();
}
}

View File

@ -50,9 +50,6 @@ DIALOG_CLEANUP_GRAPHICS::DIALOG_CLEANUP_GRAPHICS( PCB_BASE_FRAME* aParent, bool
DIALOG_CLEANUP_GRAPHICS::~DIALOG_CLEANUP_GRAPHICS()
{
for( CLEANUP_ITEM* item : m_items )
delete item;
m_changesTreeModel->DecRef();
}
@ -97,9 +94,6 @@ void DIALOG_CLEANUP_GRAPHICS::doCleanup( bool aDryRun )
m_changesTreeModel->SetProvider( nullptr );
}
for( CLEANUP_ITEM* item : m_items )
delete item;
m_items.clear();
// Old model has to be refreshed, GAL normally does not keep updating it

View File

@ -36,7 +36,7 @@ class DIALOG_CLEANUP_GRAPHICS: public DIALOG_CLEANUP_GRAPHICS_BASE
{
PCB_BASE_FRAME* m_parentFrame;
bool m_isModEdit;
std::vector<CLEANUP_ITEM*> m_items;
std::vector<std::shared_ptr<CLEANUP_ITEM> > m_items;
RC_TREE_MODEL* m_changesTreeModel;
void doCleanup( bool aDryRun );

View File

@ -71,9 +71,6 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS::~DIALOG_CLEANUP_TRACKS_AND_VIAS()
cfg->m_Cleanup.cleanup_tracks_in_pad = m_deleteTracksInPadsOpt->GetValue();
cfg->m_Cleanup.delete_dangling_vias = m_deleteDanglingViasOpt->GetValue();
for( CLEANUP_ITEM* item : m_items )
delete item;
m_changesTreeModel->DecRef();
}
@ -115,9 +112,6 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup( bool aDryRun )
m_changesTreeModel->SetProvider( nullptr );
}
for( CLEANUP_ITEM* item : m_items )
delete item;
m_items.clear();
// Old model has to be refreshed, GAL normally does not keep updating it

View File

@ -35,7 +35,7 @@ class PCB_EDIT_FRAME;
class DIALOG_CLEANUP_TRACKS_AND_VIAS: public DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE
{
PCB_EDIT_FRAME* m_parentFrame;
std::vector<CLEANUP_ITEM*> m_items;
std::vector<std::shared_ptr<CLEANUP_ITEM> > m_items;
RC_TREE_MODEL* m_changesTreeModel;
void doCleanup( bool aDryRun );

View File

@ -306,7 +306,7 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
if( !node )
return;
RC_ITEM* rcItem = node->m_RcItem;
std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
wxString listName;
wxMenu menu;
wxString msg;

View File

@ -190,11 +190,11 @@ void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event )
return;
HTML_MESSAGE_BOX dlg( this, _( "Check footprints" ) );
std::vector<DRC_ITEM*> drcItems;
std::vector<std::shared_ptr<DRC_ITEM> > drcItems;
TestFootprints( netlist, m_parent->GetBoard(), drcItems );
for( DRC_ITEM* item : drcItems )
for( auto item : drcItems )
dlg.AddHTML_Text( item->ShowHtml( m_parent ) );
dlg.ShowModal();

View File

@ -47,6 +47,7 @@
#include <netlist_reader/pcb_netlist.h>
#include <math/util.h> // for KiROUND
#include <dialog_drc.h>
#include <wx/progdlg.h>
#include <board_commit.h>
#include <geometry/shape_segment.h>
#include <geometry/shape_arc.h>
@ -86,11 +87,6 @@ DRC::DRC() :
DRC::~DRC()
{
for( DRC_ITEM* unconnectedItem : m_unconnected )
delete unconnectedItem;
for( DRC_ITEM* footprintItem : m_footprints )
delete footprintItem;
}
@ -377,9 +373,6 @@ void DRC::RunTests( wxTextCtrl* aMessages )
tester.RunDRC( userUnits(), *m_pcb );
}
for( DRC_ITEM* footprintItem : m_footprints )
delete footprintItem;
m_footprints.clear();
m_footprintsTested = false;
@ -513,7 +506,7 @@ void DRC::testPadClearances( BOARD_COMMIT& aCommit )
if( pad->Collide( &edge, minClearance, &actual ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_COPPER_EDGE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_COPPER_EDGE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,
@ -609,7 +602,7 @@ void DRC::testTracks( BOARD_COMMIT& aCommit, wxWindow *aActiveWindow, bool aShow
if( !settings.Ignore( code ) && connectivity->TestTrackEndpointDangling( *seg_it, &pos ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( code );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( code );
drcItem->SetItems( *seg_it );
MARKER_PCB* marker = new MARKER_PCB( drcItem, pos );
@ -624,9 +617,6 @@ void DRC::testTracks( BOARD_COMMIT& aCommit, wxWindow *aActiveWindow, bool aShow
void DRC::testUnconnected()
{
for( DRC_ITEM* unconnectedItem : m_unconnected )
delete unconnectedItem;
m_unconnected.clear();
auto connectivity = m_pcb->GetConnectivity();
@ -640,7 +630,7 @@ void DRC::testUnconnected()
for( const CN_EDGE& edge : edges )
{
DRC_ITEM* item = DRC_ITEM::Create( DRCE_UNCONNECTED_ITEMS );
std::shared_ptr<DRC_ITEM> item = DRC_ITEM::Create( DRCE_UNCONNECTED_ITEMS );
item->SetItems( edge.GetSourceNode()->Parent(), edge.GetTargetNode()->Parent() );
m_unconnected.push_back( item );
}
@ -677,7 +667,7 @@ void DRC::testZones( BOARD_COMMIT& aCommit )
if( ( netcode < 0 ) || pads_in_net == 0 )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_ZONE_HAS_EMPTY_NET );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ZONE_HAS_EMPTY_NET );
drcItem->SetItems( zone );
MARKER_PCB* marker = new MARKER_PCB( drcItem, zone->GetPosition() );
@ -743,7 +733,7 @@ void DRC::testZones( BOARD_COMMIT& aCommit )
if( smoothed_polys[ia2].Contains( currentVertex ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_ZONES_INTERSECT );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ZONES_INTERSECT );
drcItem->SetItems( zoneRef, zoneToTest );
MARKER_PCB* marker = new MARKER_PCB( drcItem, pt );
@ -759,7 +749,7 @@ void DRC::testZones( BOARD_COMMIT& aCommit )
if( smoothed_polys[ia].Contains( currentVertex ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_ZONES_INTERSECT );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ZONES_INTERSECT );
drcItem->SetItems( zoneToTest, zoneRef );
MARKER_PCB* marker = new MARKER_PCB( drcItem, pt );
@ -814,7 +804,7 @@ void DRC::testZones( BOARD_COMMIT& aCommit )
for( const std::pair<const wxPoint, int>& conflict : conflictPoints )
{
int actual = conflict.second;
DRC_ITEM* drcItem;
std::shared_ptr<DRC_ITEM> drcItem;
if( actual <= 0 )
{
@ -943,7 +933,7 @@ void DRC::testCopperDrawItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem )
if( actual < INT_MAX )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,
@ -988,7 +978,7 @@ void DRC::testCopperDrawItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem )
if( actual < INT_MAX )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,
@ -1021,7 +1011,7 @@ void DRC::testOutline( BOARD_COMMIT& aCommit )
}
else
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
m_msg.Printf( drcItem->GetErrorText() + _( " (not a closed shape)" ) );
@ -1045,7 +1035,7 @@ void DRC::testDisabledLayers( BOARD_COMMIT& aCommit )
{
if( disabledLayers.test( track->GetLayer() ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM );
m_msg.Printf( drcItem->GetErrorText() + _( "layer %s" ),
track->GetLayerName() );
@ -1065,7 +1055,7 @@ void DRC::testDisabledLayers( BOARD_COMMIT& aCommit )
{
if( disabledLayers.test( child->GetLayer() ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM );
m_msg.Printf( drcItem->GetErrorText() + _( "layer %s" ),
child->GetLayerName() );
@ -1083,7 +1073,7 @@ void DRC::testDisabledLayers( BOARD_COMMIT& aCommit )
{
if( disabledLayers.test( zone->GetLayer() ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM );
m_msg.Printf( drcItem->GetErrorText() + _( "layer %s" ),
zone->GetLayerName() );
@ -1147,7 +1137,7 @@ bool DRC::doPadToPadsDrc( BOARD_COMMIT& aCommit, D_PAD* aRefPad, D_PAD** aStart,
if( aRefPad->Collide( pad->GetEffectiveHoleShape(), minClearance, &actual ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,
@ -1165,13 +1155,12 @@ bool DRC::doPadToPadsDrc( BOARD_COMMIT& aCommit, D_PAD* aRefPad, D_PAD** aStart,
if( aRefPad->GetDrillSize().x )
{
int minClearance = pad->GetClearance( pad->GetLayer(), nullptr,
&m_clearanceSource );
int minClearance = pad->GetClearance( nullptr, &m_clearanceSource );
int actual;
if( pad->Collide( aRefPad->GetEffectiveHoleShape(), minClearance, &actual ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,
@ -1202,7 +1191,7 @@ bool DRC::doPadToPadsDrc( BOARD_COMMIT& aCommit, D_PAD* aRefPad, D_PAD** aStart,
if( pad->GetNetCode() && aRefPad->GetNetCode()
&& pad->GetNetCode() != aRefPad->GetNetCode() )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_SHORTING_ITEMS );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_SHORTING_ITEMS );
m_msg.Printf( drcItem->GetErrorText() + _( " (nets %s and %s)" ),
pad->GetNetname(), aRefPad->GetNetname() );
@ -1232,7 +1221,7 @@ bool DRC::doPadToPadsDrc( BOARD_COMMIT& aCommit, D_PAD* aRefPad, D_PAD** aStart,
if( aRefPad->Collide( pad, clearanceAllowed, &actual ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,

View File

@ -128,8 +128,8 @@ private:
bool m_board_outline_valid;
DIALOG_DRC* m_drcDialog;
std::vector<DRC_ITEM*> m_unconnected; // list of unconnected pads
std::vector<DRC_ITEM*> m_footprints; // list of footprint warnings
std::vector<std::shared_ptr<DRC_ITEM> > m_unconnected; // list of unconnected pads
std::vector<std::shared_ptr<DRC_ITEM> > m_footprints; // list of footprint warnings
bool m_drcRun; // indicates DRC has been run at least once
bool m_footprintsTested; // indicates footprints were tested in last run

View File

@ -44,7 +44,7 @@ void DRC::doSingleViaDRC( BOARD_COMMIT& aCommit, VIA* aRefVia )
{
if( aRefVia->GetWidth() < bds.m_MicroViasMinSize )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_MICROVIA );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_VIA_ANNULUS );
m_msg.Printf( drcItem->GetErrorText() + _( " (board minimum %s; actual %s)" ),
MessageTextFromValue( userUnits(), bds.m_MicroViasMinSize, true ),
@ -61,7 +61,7 @@ void DRC::doSingleViaDRC( BOARD_COMMIT& aCommit, VIA* aRefVia )
{
if( aRefVia->GetWidth() < bds.m_ViasMinSize )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_VIA );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_VIA_ANNULUS );
m_msg.Printf( drcItem->GetErrorText() + _( " (board minimum %s; actual %s)" ),
MessageTextFromValue( userUnits(), bds.m_ViasMinSize, true ),
@ -80,7 +80,7 @@ void DRC::doSingleViaDRC( BOARD_COMMIT& aCommit, VIA* aRefVia )
// and a default via hole can be bigger than some vias sizes
if( aRefVia->GetDrillValue() > aRefVia->GetWidth() )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_VIA_HOLE_BIGGER );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_VIA_HOLE_BIGGER );
m_msg.Printf( drcItem->GetErrorText() + _( " (diameter %s; drill %s)" ),
MessageTextFromValue( userUnits(), aRefVia->GetWidth(), true ),
@ -96,7 +96,7 @@ void DRC::doSingleViaDRC( BOARD_COMMIT& aCommit, VIA* aRefVia )
// test if the type of via is allowed due to design rules
if( aRefVia->GetViaType() == VIATYPE::MICROVIA && !bds.m_MicroViasAllowed )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_ALLOWED_ITEMS );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ALLOWED_ITEMS );
m_msg.Printf( _( "Microvia not allowed (board design rule constraints)" ) );
drcItem->SetErrorMessage( m_msg );
@ -109,7 +109,7 @@ void DRC::doSingleViaDRC( BOARD_COMMIT& aCommit, VIA* aRefVia )
// test if the type of via is allowed due to design rules
if( aRefVia->GetViaType() == VIATYPE::BLIND_BURIED && !bds.m_BlindBuriedViaAllowed )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_ALLOWED_ITEMS );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ALLOWED_ITEMS );
m_msg.Printf( _( "Blind/buried via not allowed (board design rule constraints)" ) );
drcItem->SetErrorMessage( m_msg );
@ -141,7 +141,7 @@ void DRC::doSingleViaDRC( BOARD_COMMIT& aCommit, VIA* aRefVia )
if( err )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_PADSTACK );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_PADSTACK );
m_msg.Printf( _( "Microvia through too many layers (%s and %s not adjacent)" ),
m_pcb->GetLayerName( layer1 ),
@ -184,7 +184,7 @@ void DRC::doSingleTrackDRC( BOARD_COMMIT& aCommit, TRACK* aRefSeg )
{
wxPoint refsegMiddle = ( aRefSeg->GetStart() + aRefSeg->GetEnd() ) / 2;
DRC_ITEM* drcItem = DRC_ITEM::Create( errorCode );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( errorCode );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ),
m_clearanceSource,
@ -322,7 +322,7 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS
if( slot->Collide( &refSeg, minClearance + bds.GetDRCEpsilon(), &actual ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,
@ -350,7 +350,7 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS
if( pad->Collide( &refSeg, minClearance - bds.GetDRCEpsilon(), &actual ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,
@ -409,7 +409,7 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS
// Check two tracks crossing first as it reports a DRCE without distances
if( OPT_VECTOR2I intersection = refSeg.GetSeg().Intersect( trackSeg.GetSeg() ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_TRACKS_CROSSING );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TRACKS_CROSSING );
drcItem->SetErrorMessage( m_msg );
drcItem->SetItems( aRefSeg, track );
@ -422,7 +422,7 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS
else if( refSeg.Collide( &trackSeg, minClearance, &actual ) )
{
wxPoint pos = GetLocation( aRefSeg, trackSeg.GetSeg() );
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,
@ -471,7 +471,7 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS
if( zone->GetFilledPolysList( aLayer ).Collide( testSeg, allowedDist, &actual ) )
{
actual = std::max( 0, actual - halfWidth );
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,
@ -535,7 +535,7 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS
BOARD::IterateForward<BOARD_ITEM*>( m_pcb->Drawings(), inspector, nullptr, types );
int actual = std::max( 0.0, sqrt( center2center_squared ) - halfWidth );
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_COPPER_EDGE_CLEARANCE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_COPPER_EDGE_CLEARANCE );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s clearance %s; actual %s)" ),
m_clearanceSource,

View File

@ -56,7 +56,7 @@ bool DRC_COURTYARD_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard )
&& footprint->GetPolyCourtyardFront().OutlineCount() == 0
&& footprint->GetPolyCourtyardBack().OutlineCount() == 0 )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_MISSING_COURTYARD );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_MISSING_COURTYARD );
drcItem->SetItems( footprint );
HandleMarker( new MARKER_PCB( drcItem, footprint->GetPosition() ) );
success = false;
@ -71,7 +71,7 @@ bool DRC_COURTYARD_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard )
{
if( !aBoard.GetDesignSettings().Ignore( DRCE_MALFORMED_COURTYARD ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_MALFORMED_COURTYARD );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_MALFORMED_COURTYARD );
msg.Printf( drcItem->GetErrorText() + _( " (not a closed shape)" ) );
@ -137,7 +137,7 @@ bool DRC_COURTYARD_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard )
if( overlap )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS );
drcItem->SetItems( footprint, test );
HandleMarker( new MARKER_PCB( drcItem, pos ) );
success = false;
@ -175,7 +175,7 @@ bool DRC_COURTYARD_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard )
int code = pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED ?
DRCE_NPTH_IN_COURTYARD :
DRCE_PTH_IN_COURTYARD;
DRC_ITEM* drcItem = DRC_ITEM::Create( code );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( code );
drcItem->SetItems( footprint, pad );
HandleMarker( new MARKER_PCB( drcItem, pos ) );
success = false;

View File

@ -110,7 +110,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkPad( D_PAD* aPad )
if( holeSize < minHole )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_DRILL );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_DRILL );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ),
m_source,
@ -161,7 +161,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkVia( VIA* via )
if( via->GetDrillValue() < minHole )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_DRILL );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_DRILL );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ),
m_source,
@ -213,7 +213,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkMicroVia( VIA* via )
if( via->GetDrillValue() < minHole )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_MICROVIA_DRILL );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_MICROVIA_DRILL );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ),
m_source,
@ -288,7 +288,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkHoles()
if( actual < bds.m_HoleToHoleMin )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_DRILLED_HOLES_TOO_CLOSE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_DRILLED_HOLES_TOO_CLOSE );
m_msg.Printf( drcItem->GetErrorText() + _( " (board minimum %s; actual %s)" ),
MessageTextFromValue( m_units, bds.m_HoleToHoleMin, true ),

View File

@ -199,55 +199,59 @@ std::vector<std::reference_wrapper<RC_ITEM>> DRC_ITEM::allItemTypes( {
} );
DRC_ITEM* DRC_ITEM::Create( int aErrorCode )
std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( int aErrorCode )
{
DRC_ITEM *item = nullptr;
switch( aErrorCode )
{
case DRCE_UNCONNECTED_ITEMS: return new DRC_ITEM( unconnectedItems );
case DRCE_SHORTING_ITEMS: return new DRC_ITEM( shortingItems );
case DRCE_ALLOWED_ITEMS: return new DRC_ITEM( itemsNotAllowed );
case DRCE_CLEARANCE: return new DRC_ITEM( clearance );
case DRCE_TRACKS_CROSSING: return new DRC_ITEM( tracksCrossing );
case DRCE_COPPER_EDGE_CLEARANCE: return new DRC_ITEM( copperEdgeClearance );
case DRCE_ZONES_INTERSECT: return new DRC_ITEM( zonesIntersect );
case DRCE_ZONE_HAS_EMPTY_NET: return new DRC_ITEM( zoneHasEmptyNet );
case DRCE_DANGLING_VIA: return new DRC_ITEM( viaDangling );
case DRCE_DANGLING_TRACK: return new DRC_ITEM( trackDangling );
case DRCE_DRILLED_HOLES_TOO_CLOSE: return new DRC_ITEM( holeNearHole );
case DRCE_TRACK_WIDTH: return new DRC_ITEM( trackWidth );
case DRCE_TOO_SMALL_VIA: return new DRC_ITEM( viaTooSmall );
case DRCE_VIA_ANNULUS: return new DRC_ITEM( viaAnnulus );
case DRCE_TOO_SMALL_DRILL: return new DRC_ITEM( drillTooSmall );
case DRCE_VIA_HOLE_BIGGER: return new DRC_ITEM( viaHoleLargerThanPad );
case DRCE_PADSTACK: return new DRC_ITEM( padstack );
case DRCE_TOO_SMALL_MICROVIA: return new DRC_ITEM( microviaTooSmall );
case DRCE_TOO_SMALL_MICROVIA_DRILL: return new DRC_ITEM( microviaDrillTooSmall );
case DRCE_KEEPOUT: return new DRC_ITEM( keepout );
case DRCE_OVERLAPPING_FOOTPRINTS: return new DRC_ITEM( courtyardsOverlap );
case DRCE_MISSING_COURTYARD: return new DRC_ITEM( missingCourtyard );
case DRCE_MALFORMED_COURTYARD: return new DRC_ITEM( malformedCourtyard );
case DRCE_PTH_IN_COURTYARD: return new DRC_ITEM( pthInsideCourtyard );
case DRCE_NPTH_IN_COURTYARD: return new DRC_ITEM( npthInsideCourtyard );
case DRCE_DISABLED_LAYER_ITEM: return new DRC_ITEM( itemOnDisabledLayer );
case DRCE_INVALID_OUTLINE: return new DRC_ITEM( invalidOutline );
case DRCE_MISSING_FOOTPRINT: return new DRC_ITEM( duplicateFootprints );
case DRCE_DUPLICATE_FOOTPRINT: return new DRC_ITEM( missingFootprint );
case DRCE_EXTRA_FOOTPRINT: return new DRC_ITEM( extraFootprint );
case DRCE_UNRESOLVED_VARIABLE: return new DRC_ITEM( unresolvedVariable );
case DRCE_UNCONNECTED_ITEMS: item = new DRC_ITEM( unconnectedItems ); break;
case DRCE_SHORTING_ITEMS: item = new DRC_ITEM( shortingItems ); break;
case DRCE_ALLOWED_ITEMS: item = new DRC_ITEM( itemsNotAllowed ); break;
case DRCE_CLEARANCE: item = new DRC_ITEM( clearance ); break;
case DRCE_TRACKS_CROSSING: item = new DRC_ITEM( tracksCrossing ); break;
case DRCE_COPPER_EDGE_CLEARANCE: item = new DRC_ITEM( copperEdgeClearance ); break;
case DRCE_ZONES_INTERSECT: item = new DRC_ITEM( zonesIntersect ); break;
case DRCE_ZONE_HAS_EMPTY_NET: item = new DRC_ITEM( zoneHasEmptyNet ); break;
case DRCE_DANGLING_VIA: item = new DRC_ITEM( viaDangling ); break;
case DRCE_DANGLING_TRACK: item = new DRC_ITEM( trackDangling ); break;
case DRCE_DRILLED_HOLES_TOO_CLOSE: item = new DRC_ITEM( holeNearHole ); break;
case DRCE_TRACK_WIDTH: item = new DRC_ITEM( trackWidth ); break;
case DRCE_TOO_SMALL_VIA: item = new DRC_ITEM( viaTooSmall ); break;
case DRCE_VIA_ANNULUS: item = new DRC_ITEM( viaAnnulus ); break;
case DRCE_TOO_SMALL_DRILL: item = new DRC_ITEM( drillTooSmall ); break;
case DRCE_VIA_HOLE_BIGGER: item = new DRC_ITEM( viaHoleLargerThanPad ); break;
case DRCE_PADSTACK: item = new DRC_ITEM( padstack ); break;
case DRCE_TOO_SMALL_MICROVIA: item = new DRC_ITEM( microviaTooSmall ); break;
case DRCE_TOO_SMALL_MICROVIA_DRILL: item = new DRC_ITEM( microviaDrillTooSmall ); break;
case DRCE_KEEPOUT: item = new DRC_ITEM( keepout ); break;
case DRCE_OVERLAPPING_FOOTPRINTS: item = new DRC_ITEM( courtyardsOverlap ); break;
case DRCE_MISSING_COURTYARD: item = new DRC_ITEM( missingCourtyard ); break;
case DRCE_MALFORMED_COURTYARD: item = new DRC_ITEM( malformedCourtyard ); break;
case DRCE_PTH_IN_COURTYARD: item = new DRC_ITEM( pthInsideCourtyard ); break;
case DRCE_NPTH_IN_COURTYARD: item = new DRC_ITEM( npthInsideCourtyard ); break;
case DRCE_DISABLED_LAYER_ITEM: item = new DRC_ITEM( itemOnDisabledLayer ); break;
case DRCE_INVALID_OUTLINE: item = new DRC_ITEM( invalidOutline ); break;
case DRCE_MISSING_FOOTPRINT: item = new DRC_ITEM( duplicateFootprints ); break;
case DRCE_DUPLICATE_FOOTPRINT: item = new DRC_ITEM( missingFootprint ); break;
case DRCE_EXTRA_FOOTPRINT: item = new DRC_ITEM( extraFootprint ); break;
case DRCE_UNRESOLVED_VARIABLE: item = new DRC_ITEM( unresolvedVariable ); break;
default:
wxFAIL_MSG( "Unknown DRC error code" );
return nullptr;
}
return std::shared_ptr<DRC_ITEM>( item );
}
DRC_ITEM* DRC_ITEM::Create( const wxString& aErrorKey )
std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( const wxString& aErrorKey )
{
for( const RC_ITEM& item : allItemTypes )
{
if( aErrorKey == item.GetSettingsKey() )
return new DRC_ITEM( static_cast<const DRC_ITEM&>( item ) );
return std::shared_ptr<DRC_ITEM>( new DRC_ITEM( static_cast<const DRC_ITEM&>( item ) ) );
}
// This can happen if a project has old-format exclusions. Just drop these items.

View File

@ -36,7 +36,7 @@ public:
* Constructs a DRC_ITEM for the given error code
* @see DRCE_T
*/
static DRC_ITEM* Create( int aErrorCode );
static std::shared_ptr<DRC_ITEM> Create( int aErrorCode );
/**
* Constructs a DRC item from a given error settings key
@ -44,7 +44,7 @@ public:
* to represent a given error code in settings files and for storing ignored DRC items)
* @return the created item
*/
static DRC_ITEM* Create( const wxString& aErrorKey );
static std::shared_ptr<DRC_ITEM> Create( const wxString& aErrorKey );
static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
{

View File

@ -95,7 +95,7 @@ bool DRC_KEEPOUT_TESTER::checkTracksAndVias()
if( m_zone->Outline()->Collide( trackSeg, segm->GetWidth() / 2 ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s)" ),
m_sources.at( DISALLOW_TRACKS ) );
@ -138,7 +138,7 @@ bool DRC_KEEPOUT_TESTER::checkTracksAndVias()
if( m_zone->Outline()->Collide( seg, clearance ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s)" ), m_sources.at( test ) );
drcItem->SetErrorMessage( m_msg );
drcItem->SetItems( segm, m_zone );
@ -187,7 +187,7 @@ bool DRC_KEEPOUT_TESTER::checkFootprints()
if( poly.OutlineCount() )
{
const VECTOR2I& pt = poly.CVertex( 0, 0, -1 );
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s)" ),
m_sources.at( DISALLOW_FOOTPRINTS ) );
@ -237,7 +237,7 @@ bool DRC_KEEPOUT_TESTER::checkPads( MODULE* aModule )
if( outline.OutlineCount() )
{
const VECTOR2I& pt = outline.CVertex( 0, 0, -1 );
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s)" ),
m_sources.at( DISALLOW_PADS ) );
@ -255,7 +255,7 @@ bool DRC_KEEPOUT_TESTER::checkPads( MODULE* aModule )
if( m_zone->Outline()->Collide( slot->GetSeg(), slot->GetWidth() / 2 ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s)" ),
m_sources.at( DISALLOW_HOLES ) );
@ -307,7 +307,7 @@ bool DRC_KEEPOUT_TESTER::checkDrawings()
if( poly.OutlineCount() )
{
const VECTOR2I& pt = poly.CVertex( 0, 0, -1 );
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_KEEPOUT );
m_msg.Printf( drcItem->GetErrorText() + _( " (%s)" ), m_sources.at( sourceId ) );
drcItem->SetErrorMessage( m_msg );
drcItem->SetItems( drawing, m_zone );

View File

@ -144,11 +144,11 @@ public:
return count;
}
DRC_ITEM* GetItem( int aIndex ) override
std::shared_ptr<RC_ITEM> GetItem( int aIndex ) override
{
MARKER_PCB* marker = m_filteredMarkers[ aIndex ];
return marker ? static_cast<DRC_ITEM*>( marker->GetRCItem() ) : nullptr;
return marker ? marker->GetRCItem() : nullptr;
}
void DeleteItem( int aIndex, bool aDeep ) override
@ -179,14 +179,14 @@ public:
class VECTOR_DRC_ITEMS_PROVIDER : public RC_ITEMS_PROVIDER
{
PCB_BASE_FRAME* m_frame;
std::vector<DRC_ITEM*>* m_sourceVector; // owns its DRC_ITEMs
std::vector<std::shared_ptr<DRC_ITEM> >* m_sourceVector; // owns its DRC_ITEMs
int m_severities;
std::vector<DRC_ITEM*> m_filteredVector; // does not own its DRC_ITEMs
std::vector<std::shared_ptr<DRC_ITEM> > m_filteredVector; // does not own its DRC_ITEMs
public:
VECTOR_DRC_ITEMS_PROVIDER( PCB_BASE_FRAME* aFrame, std::vector<DRC_ITEM*>* aList ) :
VECTOR_DRC_ITEMS_PROVIDER( PCB_BASE_FRAME* aFrame, std::vector<std::shared_ptr<DRC_ITEM> >* aList ) :
m_frame( aFrame ),
m_sourceVector( aList ),
m_severities( 0 )
@ -203,7 +203,7 @@ public:
if( m_sourceVector )
{
for( DRC_ITEM* item : *m_sourceVector )
for( auto item : *m_sourceVector )
{
if( bds.GetSeverity( item->GetErrorCode() ) & aSeverities )
m_filteredVector.push_back( item );
@ -221,7 +221,7 @@ public:
if( m_sourceVector )
{
for( DRC_ITEM* item : *m_sourceVector )
for( auto item : *m_sourceVector )
{
if( bds.GetSeverity( item->GetErrorCode() ) == aSeverity )
count++;
@ -231,14 +231,14 @@ public:
return count;
}
DRC_ITEM* GetItem( int aIndex ) override
std::shared_ptr<RC_ITEM> GetItem( int aIndex ) override
{
return (m_filteredVector)[aIndex];
}
void DeleteItem( int aIndex, bool aDeep ) override
{
DRC_ITEM* item = m_filteredVector[aIndex];
auto item = m_filteredVector[aIndex];
m_filteredVector.erase( m_filteredVector.begin() + aIndex );
if( aDeep )
@ -247,7 +247,6 @@ public:
{
if( m_sourceVector->at( i ) == item )
{
delete item;
m_sourceVector->erase( m_sourceVector->begin() + i );
break;
}
@ -259,9 +258,6 @@ public:
{
if( aDeep )
{
for( DRC_ITEM* item : *m_sourceVector )
delete item;
m_sourceVector->clear();
}
@ -279,7 +275,7 @@ class RATSNEST_DRC_ITEMS_PROVIDER : public VECTOR_DRC_ITEMS_PROVIDER
// data-structure so that deleting/excluding things can do a deep delete/exclusion
// which will be reflected in the ratsnest....
public:
RATSNEST_DRC_ITEMS_PROVIDER( PCB_BASE_FRAME* aFrame, std::vector<DRC_ITEM*>* aList ) :
RATSNEST_DRC_ITEMS_PROVIDER( PCB_BASE_FRAME* aFrame, std::vector<std::shared_ptr<DRC_ITEM> >* aList ) :
VECTOR_DRC_ITEMS_PROVIDER( aFrame, aList )
{ }
};

View File

@ -119,7 +119,7 @@ bool DRC_RULE_CONDITION::EvaluateFor( const BOARD_ITEM* aItemA, const BOARD_ITEM
bool DRC_RULE_CONDITION::Compile( REPORTER* aReporter, int aSourceLine, int aSourceOffset )
{
PCB_EXPR_COMPILER compiler( aReporter, aSourceLine, aSourceOffset );
PCB_EXPR_COMPILER compiler;
if (!m_ucode)
m_ucode = new PCB_EXPR_UCODE;

View File

@ -376,7 +376,9 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule )
void DRC_RULES_PARSER::parseValueWithUnits( const wxString& aExpr, int& aResult )
{
PCB_EXPR_EVALUATOR evaluator( m_reporter, CurLineNumber(), CurOffset() );
PCB_EXPR_EVALUATOR evaluator;
// m_reporter, CurLineNumber(), CurOffset() );
evaluator.Evaluate( aExpr );
aResult = evaluator.Result();

View File

@ -57,7 +57,7 @@ bool DRC_TEXTVAR_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard )
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
drcItem->SetItems( text );
HandleMarker( new MARKER_PCB( drcItem, text->GetPosition() ) );
@ -75,7 +75,7 @@ bool DRC_TEXTVAR_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard )
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
drcItem->SetItems( text );
HandleMarker( new MARKER_PCB( drcItem, text->GetPosition() ) );
@ -98,7 +98,7 @@ bool DRC_TEXTVAR_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard )
{
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
{
DRC_ITEM* drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
drcItem->SetErrorMessage( _( "Unresolved text variable in worksheet." ) );
HandleMarker( new MARKER_PCB( drcItem, text->GetPosition() ) );

View File

@ -26,7 +26,7 @@
#include <drc/footprint_tester.h>
#include <drc/drc_item.h>
void TestFootprints( NETLIST& aNetlist, BOARD* aBoard, std::vector<DRC_ITEM*>& aDRCList )
void TestFootprints( NETLIST& aNetlist, BOARD* aBoard, std::vector<std::shared_ptr<DRC_ITEM> >& aDRCList )
{
wxString msg;
@ -45,7 +45,7 @@ void TestFootprints( NETLIST& aNetlist, BOARD* aBoard, std::vector<DRC_ITEM*>& a
if( !ins.second )
{
DRC_ITEM* item = DRC_ITEM::Create( DRCE_DUPLICATE_FOOTPRINT );
std::shared_ptr<DRC_ITEM> item = DRC_ITEM::Create( DRCE_DUPLICATE_FOOTPRINT );
item->SetItems( mod, *ins.first );
aDRCList.push_back( item );
}
@ -66,7 +66,7 @@ void TestFootprints( NETLIST& aNetlist, BOARD* aBoard, std::vector<DRC_ITEM*>& a
component->GetReference(),
component->GetValue() );
DRC_ITEM* item = DRC_ITEM::Create( DRCE_MISSING_FOOTPRINT );
std::shared_ptr<DRC_ITEM> item = DRC_ITEM::Create( DRCE_MISSING_FOOTPRINT );
item->SetErrorMessage( msg );
aDRCList.push_back( item );
}
@ -82,7 +82,7 @@ void TestFootprints( NETLIST& aNetlist, BOARD* aBoard, std::vector<DRC_ITEM*>& a
if( component == NULL )
{
DRC_ITEM* item = DRC_ITEM::Create( DRCE_EXTRA_FOOTPRINT );
std::shared_ptr<DRC_ITEM> item = DRC_ITEM::Create( DRCE_EXTRA_FOOTPRINT );
item->SetItems( module );
aDRCList.push_back( item );
}

View File

@ -29,6 +29,6 @@
class BOARD;
void TestFootprints( NETLIST& aNetlist, BOARD* aBoard, std::vector<DRC_ITEM*>& aDRCList );
void TestFootprints( NETLIST& aNetlist, BOARD* aBoard, std::vector<std::shared_ptr<DRC_ITEM> >& aDRCList );
#endif // FOOTPRINT_TESTER_H

View File

@ -43,7 +43,7 @@ GRAPHICS_CLEANER::GRAPHICS_CLEANER( DRAWINGS& aDrawings, MODULE* aParentModule,
}
void GRAPHICS_CLEANER::CleanupBoard( bool aDryRun, std::vector<CLEANUP_ITEM*>* aItemsList,
void GRAPHICS_CLEANER::CleanupBoard( bool aDryRun, std::vector<std::shared_ptr<CLEANUP_ITEM> >* aItemsList,
bool aMergeRects, bool aDeleteRedundant )
{
m_dryRun = aDryRun;
@ -146,7 +146,7 @@ void GRAPHICS_CLEANER::cleanupSegments()
if( isNullSegment( segment ) )
{
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_NULL_GRAPHIC );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_NULL_GRAPHIC ) );
item->SetItems( segment );
m_itemsList->push_back( item );
@ -165,7 +165,7 @@ void GRAPHICS_CLEANER::cleanupSegments()
if( areEquivalent( segment, segment2 ) )
{
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_DUPLICATE_GRAPHIC );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_DUPLICATE_GRAPHIC ) );
item->SetItems( segment2 );
m_itemsList->push_back( item );
@ -293,7 +293,7 @@ void GRAPHICS_CLEANER::mergeRects()
right->seg->SetFlags( IS_DELETED );
bottom->seg->SetFlags( IS_DELETED );
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_LINES_TO_RECT );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_LINES_TO_RECT ) );
item->SetItems( left->seg, top->seg, right->seg, bottom->seg );
m_itemsList->push_back( item );

View File

@ -42,7 +42,7 @@ public:
* @param aMergeRects = merge for segments forming a rectangle into a rect
* @param aDeleteRedundant = true to delete null graphics and duplicated graphics
*/
void CleanupBoard( bool aDryRun, std::vector<CLEANUP_ITEM*>* aItemsList, bool aMergeRects,
void CleanupBoard( bool aDryRun, std::vector<std::shared_ptr<CLEANUP_ITEM> >* aItemsList, bool aMergeRects,
bool aDeleteRedundant );
private:
@ -57,7 +57,7 @@ private:
MODULE* m_parentModule; // nullptr if not in ModEdit
BOARD_COMMIT& m_commit;
bool m_dryRun;
std::vector<CLEANUP_ITEM*>* m_itemsList;
std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_itemsList;
};

View File

@ -199,7 +199,7 @@ static void insideArea( LIBEVAL::CONTEXT* aCtx, void* self )
PCB_EXPR_BUILTIN_FUNCTIONS::PCB_EXPR_BUILTIN_FUNCTIONS()
{
auto registerFunc = [&]( const wxString& funcSignature, FPTR funcPtr )
auto registerFunc = [&]( const wxString& funcSignature, LIBEVAL::FUNC_CALL_REF funcPtr )
{
wxString funcName = funcSignature.BeforeFirst( '(' );
m_funcs[ std::string( funcName.Lower() ) ] = std::move( funcPtr );
@ -262,7 +262,7 @@ LIBEVAL::VALUE PCB_EXPR_VAR_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
}
LIBEVAL::UCODE::FUNC_PTR PCB_EXPR_UCODE::CreateFuncCall( const char* aName )
LIBEVAL::FUNC_CALL_REF PCB_EXPR_UCODE::CreateFuncCall( const wxString& aName )
{
PCB_EXPR_BUILTIN_FUNCTIONS& registry = PCB_EXPR_BUILTIN_FUNCTIONS::Instance();
@ -270,28 +270,30 @@ LIBEVAL::UCODE::FUNC_PTR PCB_EXPR_UCODE::CreateFuncCall( const char* aName )
}
LIBEVAL::VAR_REF* PCB_EXPR_UCODE::CreateVarRef( const char* aVar, const char* aField )
std::unique_ptr<LIBEVAL::VAR_REF> PCB_EXPR_UCODE::CreateVarRef( const wxString& aVar, const wxString& aField )
{
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
PCB_EXPR_VAR_REF* vref = nullptr;
std::unique_ptr<PCB_EXPR_VAR_REF> vref;;
if( *aVar == 'A' )
if( aVar == "A" )
{
vref = new PCB_EXPR_VAR_REF( 0 );
vref.reset( new PCB_EXPR_VAR_REF( 0 ) );
}
else if( *aVar == 'B' )
else if( aVar == "B" )
{
vref = new PCB_EXPR_VAR_REF( 1 );
vref.reset( new PCB_EXPR_VAR_REF( 1 ) );
}
else
{
return vref;
return nullptr;
}
if( strlen( aField ) == 0 ) // return reference to base object
return vref;
if( aField.length() == 0 ) // return reference to base object
{
return std::move( vref );
}
wxString field = wxString::FromUTF8( aField );
wxString field( aField );
field.Replace( "_", " " );
for( const PROPERTY_MANAGER::CLASS_INFO& cls : propMgr.GetAllClasses() )
@ -329,7 +331,7 @@ LIBEVAL::VAR_REF* PCB_EXPR_UCODE::CreateVarRef( const char* aVar, const char* aF
if( vref->GetType() == LIBEVAL::VT_UNDEFINED )
vref->SetType( LIBEVAL::VT_PARSE_ERROR );
return vref;
return std::move( vref );
}
@ -340,16 +342,16 @@ public:
{
}
virtual const std::vector<std::string>& GetSupportedUnits() const override
virtual const std::vector<wxString>& GetSupportedUnits() const override
{
static const std::vector<std::string> pcbUnits = { "mil", "mm", "in" };
static const std::vector<wxString> pcbUnits = { "mil", "mm", "in" };
return pcbUnits;
}
virtual double Convert( const std::string& aString, int unitId ) const override
virtual double Convert( const wxString& aString, int unitId ) const override
{
double v = atof( aString.c_str() );
double v = wxAtof( aString );
switch( unitId )
{
@ -362,15 +364,13 @@ public:
};
PCB_EXPR_COMPILER::PCB_EXPR_COMPILER( REPORTER* aReporter, int aSourceLine, int aSourcePos ) :
COMPILER( aReporter, aSourceLine, aSourcePos )
PCB_EXPR_COMPILER::PCB_EXPR_COMPILER()
{
m_unitResolver = std::make_unique<PCB_UNIT_RESOLVER>();
}
PCB_EXPR_EVALUATOR::PCB_EXPR_EVALUATOR( REPORTER* aReporter, int aSourceLine, int aSourceOffset ) :
m_compiler( aReporter, aSourceLine, aSourceOffset )
PCB_EXPR_EVALUATOR::PCB_EXPR_EVALUATOR()
{
m_result = 0;
}

View File

@ -43,9 +43,8 @@ public:
PCB_EXPR_UCODE() {};
virtual ~PCB_EXPR_UCODE() {};
virtual LIBEVAL::VAR_REF* CreateVarRef( const char* aVar, const char* aField ) override;
virtual FUNC_PTR CreateFuncCall( const char* aName ) override;
virtual std::unique_ptr<LIBEVAL::VAR_REF> CreateVarRef( const wxString& aVar, const wxString& aField ) override;
virtual LIBEVAL::FUNC_CALL_REF CreateFuncCall( const wxString& aName ) override;
};
@ -92,6 +91,8 @@ public:
//printf("*** CreateVarRef %p %d\n", this, aItemIndex );
}
~PCB_EXPR_VAR_REF() {};
void SetIsEnum( bool s ) { m_isEnum = s; }
bool IsEnum() const { return m_isEnum; }
@ -128,7 +129,7 @@ public:
return self;
}
LIBEVAL::UCODE::FUNC_PTR Get( const wxString &name )
LIBEVAL::FUNC_CALL_REF Get( const std::string &name )
{
return m_funcs[ name ];
}
@ -139,7 +140,7 @@ public:
}
private:
std::map<wxString, LIBEVAL::UCODE::FUNC_PTR> m_funcs;
std::map<std::string, LIBEVAL::FUNC_CALL_REF> m_funcs;
wxArrayString m_funcSigs;
};
@ -155,17 +156,20 @@ public:
class PCB_EXPR_EVALUATOR
{
public:
PCB_EXPR_EVALUATOR( REPORTER* aReporter, int aSourceLine, int aSourceOffset );
PCB_EXPR_EVALUATOR( );
~PCB_EXPR_EVALUATOR();
bool Evaluate( const wxString& aExpr );
int Result() const { return m_result; }
bool IsErrorPending() const { return m_errorStatus.pendingError; }
const LIBEVAL::ERROR_STATUS& GetError() const { return m_errorStatus; }
private:
int m_result;
PCB_EXPR_COMPILER m_compiler;
PCB_EXPR_UCODE m_ucode;
LIBEVAL::ERROR_STATUS m_errorStatus;
};
#endif

View File

@ -50,7 +50,7 @@ TRACKS_CLEANER::TRACKS_CLEANER( BOARD* aPcb, BOARD_COMMIT& aCommit ) :
* - vias on pad
* - null length segments
*/
void TRACKS_CLEANER::CleanupBoard( bool aDryRun, std::vector<CLEANUP_ITEM*>* aItemsList,
void TRACKS_CLEANER::CleanupBoard( bool aDryRun, std::vector<std::shared_ptr<CLEANUP_ITEM> >* aItemsList,
bool aRemoveMisConnected, bool aCleanVias, bool aMergeSegments,
bool aDeleteUnconnected, bool aDeleteTracksinPad, bool aDeleteDanglingVias )
{
@ -109,7 +109,7 @@ void TRACKS_CLEANER::removeBadTrackSegments()
{
if( segment->GetNetCode() != testedPad->GetNetCode() )
{
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_SHORT );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_SHORT ) );
item->SetItems( segment );
m_itemsList->push_back( item );
@ -121,7 +121,7 @@ void TRACKS_CLEANER::removeBadTrackSegments()
{
if( segment->GetNetCode() != testedTrack->GetNetCode() )
{
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_SHORT );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_SHORT ) );
item->SetItems( segment );
m_itemsList->push_back( item );
@ -168,7 +168,7 @@ void TRACKS_CLEANER::cleanupVias()
if( ( pad->GetLayerSet() & all_cu ) == all_cu )
{
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_REDUNDANT_VIA );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_REDUNDANT_VIA ) );
item->SetItems( via1, pad );
m_itemsList->push_back( item );
@ -187,7 +187,7 @@ void TRACKS_CLEANER::cleanupVias()
if( via1->GetViaType() == via2->GetViaType() )
{
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_REDUNDANT_VIA );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_REDUNDANT_VIA ) );
item->SetItems( via1, via2 );
m_itemsList->push_back( item );
@ -267,7 +267,7 @@ bool TRACKS_CLEANER::deleteDanglingTracks( bool aVia )
int errorCode =
( track->Type() != PCB_VIA_T ) ?
CLEANUP_DANGLING_TRACK : CLEANUP_DANGLING_VIA;
CLEANUP_ITEM* item = new CLEANUP_ITEM( errorCode );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( errorCode ) );
item->SetItems( track );
m_itemsList->push_back( item );
@ -300,7 +300,7 @@ void TRACKS_CLEANER::deleteNullSegments( TRACKS& aTracks )
{
if( segment->IsNull() && segment->Type() == PCB_TRACE_T && !segment->IsLocked() )
{
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_ZERO_LENGTH_TRACK );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_ZERO_LENGTH_TRACK ) );
item->SetItems( segment );
m_itemsList->push_back( item );
@ -380,7 +380,7 @@ void TRACKS_CLEANER::cleanupSegments()
&& track1->GetWidth() == track2->GetWidth()
&& track1->GetLayer() == track2->GetLayer() )
{
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_DUPLICATE_TRACK );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_DUPLICATE_TRACK ) );
item->SetItems( track2 );
m_itemsList->push_back( item );
@ -489,7 +489,7 @@ bool TRACKS_CLEANER::mergeCollinearSegments( TRACK* aSeg1, TRACK* aSeg2 )
return false;
}
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_MERGE_TRACKS );
std::shared_ptr<CLEANUP_ITEM> item( new CLEANUP_ITEM( CLEANUP_MERGE_TRACKS ) );
item->SetItems( aSeg1, aSeg2 );
m_itemsList->push_back( item );

View File

@ -47,7 +47,7 @@ public:
* @param aDeleteTracksinPad = true to remove tracks fully inside pads
* @param aDeleteDanglingVias = true to remove a via that is only connected to a single layer
*/
void CleanupBoard( bool aDryRun, std::vector<CLEANUP_ITEM*>* aItemsList, bool aCleanVias,
void CleanupBoard( bool aDryRun, std::vector<std::shared_ptr<CLEANUP_ITEM> >* aItemsList, bool aCleanVias,
bool aRemoveMisConnected, bool aMergeSegments, bool aDeleteUnconnected,
bool aDeleteTracksinPad, bool aDeleteDanglingVias );
@ -102,7 +102,7 @@ private:
BOARD* m_brd;
BOARD_COMMIT& m_commit;
bool m_dryRun;
std::vector<CLEANUP_ITEM*>* m_itemsList;
std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_itemsList;
};

View File

@ -234,7 +234,7 @@ std::unique_ptr<BOARD> MakeBoard( const std::vector<COURTYARD_INVALID_TEST_MODUL
static bool InvalidMatchesExpected( BOARD& aBoard, const MARKER_PCB& aMarker,
const COURTYARD_INVALID_INFO& aInvalid )
{
const DRC_ITEM* reporter = static_cast<const DRC_ITEM*>( aMarker.GetRCItem() );
auto reporter = std::static_pointer_cast<DRC_ITEM>( aMarker.GetRCItem() );
const MODULE* item_a = dynamic_cast<MODULE*>( aBoard.GetItem( reporter->GetMainItemID() ) );
// This one is more than just a mis-match!

View File

@ -396,7 +396,7 @@ static std::vector<COURTYARD_OVERLAP_TEST_CASE> courtyard_cases = {
static bool CollisionMatchesExpected( BOARD& aBoard, const MARKER_PCB& aMarker,
const COURTYARD_COLLISION& aCollision )
{
const DRC_ITEM* reporter = static_cast<const DRC_ITEM*>( aMarker.GetRCItem() );
auto reporter = std::static_pointer_cast<DRC_ITEM>( aMarker.GetRCItem() );
const MODULE* item_a = dynamic_cast<MODULE*>( aBoard.GetItem( reporter->GetMainItemID() ) );
const MODULE* item_b = dynamic_cast<MODULE*>( aBoard.GetItem( reporter->GetAuxItemID() ) );