diff --git a/pcbnew/connectivity/connectivity_algo.cpp b/pcbnew/connectivity/connectivity_algo.cpp index 354acce95e..9e7135f825 100644 --- a/pcbnew/connectivity/connectivity_algo.cpp +++ b/pcbnew/connectivity/connectivity_algo.cpp @@ -39,11 +39,6 @@ bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem ) { - BOARD_CONNECTED_ITEM* citem = dyn_cast( aItem ); - - if( !citem ) - return false; - markItemNetAsDirty( aItem ); switch( aItem->Type() ) @@ -51,35 +46,35 @@ bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem ) case PCB_MODULE_T: for( auto pad : static_cast( aItem ) -> Pads() ) { - m_itemMap[pad].MarkItemsAsInvalid(); - m_itemMap.erase( pad ); + m_itemMap[ static_cast( pad ) ].MarkItemsAsInvalid(); + m_itemMap.erase( static_cast( pad ) ); } m_itemList.SetDirty( true ); break; case PCB_PAD_T: - m_itemMap[citem].MarkItemsAsInvalid(); - m_itemMap.erase( citem ); + m_itemMap[ static_cast( aItem ) ].MarkItemsAsInvalid(); + m_itemMap.erase( static_cast( aItem ) ); m_itemList.SetDirty( true ); break; case PCB_TRACE_T: - m_itemMap[citem].MarkItemsAsInvalid(); - m_itemMap.erase( citem ); + m_itemMap[ static_cast( aItem ) ].MarkItemsAsInvalid(); + m_itemMap.erase( static_cast( aItem ) ); m_itemList.SetDirty( true ); break; case PCB_VIA_T: - m_itemMap[citem].MarkItemsAsInvalid(); - m_itemMap.erase( citem ); + m_itemMap[ static_cast( aItem ) ].MarkItemsAsInvalid(); + m_itemMap.erase( static_cast( aItem ) ); m_itemList.SetDirty( true ); break; case PCB_ZONE_AREA_T: { - m_itemMap[citem].MarkItemsAsInvalid(); - m_itemMap.erase ( citem ); + m_itemMap[ static_cast( aItem ) ].MarkItemsAsInvalid(); + m_itemMap.erase ( static_cast( aItem ) ); m_itemList.SetDirty( true ); break; } diff --git a/pcbnew/connectivity/connectivity_data.cpp b/pcbnew/connectivity/connectivity_data.cpp index 8edd6b5a42..b5b7459f60 100644 --- a/pcbnew/connectivity/connectivity_data.cpp +++ b/pcbnew/connectivity/connectivity_data.cpp @@ -666,11 +666,6 @@ const std::vector CONNECTIVITY_DATA::GetRatsnestForItems( std::vector( item ); - - if( !conn_item ) - continue; - if( item->Type() == PCB_MODULE_T ) { auto component = static_cast( item ); @@ -681,8 +676,9 @@ const std::vector CONNECTIVITY_DATA::GetRatsnestForItems( std::vector( item ) ) { + item_set.insert( conn_item ); nets.insert( conn_item->GetNetCode() ); } } diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 9d45850f32..66d1629c38 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -1272,13 +1272,7 @@ void PCB_EDITOR_CONTROL::calculateSelectionRatsnest() for( auto item : selection ) { - auto board_item = static_cast( item ); - - if( board_item->Type() != PCB_MODULE_T && board_item->GetLocalRatsnestVisible() ) - { - items.push_back( board_item ); - } - else if( board_item->Type() == PCB_MODULE_T ) + if( item->Type() == PCB_MODULE_T ) { for( auto pad : static_cast( item )->Pads() ) { @@ -1286,6 +1280,11 @@ void PCB_EDITOR_CONTROL::calculateSelectionRatsnest() items.push_back( pad ); } } + else if( BOARD_CONNECTED_ITEM* boardItem = dyn_cast( item ) ) + { + if( boardItem->GetLocalRatsnestVisible() ) + items.push_back( boardItem ); + } } connectivity->ComputeDynamicRatsnest( items );