pcbnew: Prevent use of non-connected item in ratsnest
We need to be careful in the connectivity system to always use dyn_cast/dynamic_cast and check the return when dealing with board items. Getting non-connected items will result in null nets when propagated. Fixes https://gitlab.com/kicad/code/kicad/issues/5082
This commit is contained in:
parent
f46c1ccb32
commit
406de56964
|
@ -46,36 +46,36 @@ bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem )
|
|||
case PCB_MODULE_T:
|
||||
for( auto pad : static_cast<MODULE*>( aItem ) -> Pads() )
|
||||
{
|
||||
m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( pad ) ].MarkItemsAsInvalid();
|
||||
m_itemMap.erase( static_cast<BOARD_CONNECTED_ITEM*>( pad ) );
|
||||
m_itemMap[pad].MarkItemsAsInvalid();
|
||||
m_itemMap.erase( pad );
|
||||
}
|
||||
|
||||
m_itemList.SetDirty( true );
|
||||
break;
|
||||
|
||||
case PCB_PAD_T:
|
||||
m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( aItem ) ].MarkItemsAsInvalid();
|
||||
m_itemMap.erase( static_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
|
||||
m_itemMap[aItem].MarkItemsAsInvalid();
|
||||
m_itemMap.erase( aItem );
|
||||
m_itemList.SetDirty( true );
|
||||
break;
|
||||
|
||||
case PCB_TRACE_T:
|
||||
case PCB_ARC_T:
|
||||
m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( aItem ) ].MarkItemsAsInvalid();
|
||||
m_itemMap.erase( static_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
|
||||
m_itemMap[aItem].MarkItemsAsInvalid();
|
||||
m_itemMap.erase( aItem );
|
||||
m_itemList.SetDirty( true );
|
||||
break;
|
||||
|
||||
case PCB_VIA_T:
|
||||
m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( aItem ) ].MarkItemsAsInvalid();
|
||||
m_itemMap.erase( static_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
|
||||
m_itemMap[aItem].MarkItemsAsInvalid();
|
||||
m_itemMap.erase( aItem );
|
||||
m_itemList.SetDirty( true );
|
||||
break;
|
||||
|
||||
case PCB_ZONE_AREA_T:
|
||||
{
|
||||
m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( aItem ) ].MarkItemsAsInvalid();
|
||||
m_itemMap.erase ( static_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
|
||||
m_itemMap[aItem].MarkItemsAsInvalid();
|
||||
m_itemMap.erase ( aItem );
|
||||
m_itemList.SetDirty( true );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -213,7 +213,8 @@ void CONNECTIVITY_DATA::BlockRatsnestItems( const std::vector<BOARD_ITEM*>& aIte
|
|||
}
|
||||
else
|
||||
{
|
||||
citems.push_back( static_cast<BOARD_CONNECTED_ITEM*>(item) );
|
||||
if( auto citem = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
|
||||
citems.push_back( citem );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,10 +183,8 @@ int PCB_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( auto item : selection )
|
||||
{
|
||||
if( BOARD_CONNECTED_ITEM::ClassOf( item ) )
|
||||
if( auto ci = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
|
||||
{
|
||||
auto ci = static_cast<BOARD_CONNECTED_ITEM*>( item );
|
||||
|
||||
int item_net = ci->GetNetCode();
|
||||
|
||||
if( net < 0 )
|
||||
|
@ -502,7 +500,10 @@ void PCB_INSPECTION_TOOL::calculateSelectionRatsnest()
|
|||
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
BOARD_CONNECTED_ITEM* boardItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
|
||||
BOARD_CONNECTED_ITEM* boardItem = dyn_cast<BOARD_CONNECTED_ITEM*>( item );
|
||||
|
||||
if( !boardItem )
|
||||
continue;
|
||||
|
||||
if( boardItem->Type() == PCB_MODULE_T )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue