diff --git a/pcbnew/board_connected_item.h b/pcbnew/board_connected_item.h index 89120af0f3..4e0d5c7396 100644 --- a/pcbnew/board_connected_item.h +++ b/pcbnew/board_connected_item.h @@ -89,7 +89,7 @@ public: */ void SetNet( NETINFO_ITEM* aNetInfo ) { - assert( aNetInfo->GetBoard() == GetBoard() ); + wxASSERT( aNetInfo->GetBoard() == GetBoard() || aNetInfo == NETINFO_LIST::OrphanedItem() ); m_netinfo = aNetInfo; } diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index b9b6f7e093..bbe20f896a 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -1771,14 +1771,14 @@ const std::vector BOARD::AllConnectedItems() void BOARD::ClearAllNetCodes() { - for ( BOARD_CONNECTED_ITEM* item : AllConnectedItems() ) + for( BOARD_CONNECTED_ITEM* item : AllConnectedItems() ) item->SetNetCode( 0 ); } void BOARD::MapNets( const BOARD* aDestBoard ) { - for ( BOARD_CONNECTED_ITEM* item : AllConnectedItems() ) + for( BOARD_CONNECTED_ITEM* item : AllConnectedItems() ) { NETINFO_ITEM* netInfo = aDestBoard->FindNet( item->GetNetname() ); diff --git a/pcbnew/netinfo.h b/pcbnew/netinfo.h index 263e03f88c..a7460e08b0 100644 --- a/pcbnew/netinfo.h +++ b/pcbnew/netinfo.h @@ -205,8 +205,7 @@ public: */ int GetClearance() { - wxASSERT( m_NetClass ); - return m_NetClass->GetClearance(); + return m_NetClass ? m_NetClass->GetClearance() : 0; } #endif diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index c75ce9d8f8..5e5da7ea21 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -628,11 +628,19 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent ) if( !clipItem ) return 0; - if( clipItem->Type() == PCB_T ) - static_cast( clipItem )->MapNets( m_frame->GetBoard() ); - bool editModules = m_editModules || frame()->IsType( FRAME_FOOTPRINT_EDITOR ); + if( clipItem->Type() == PCB_T ) + { + if( editModules ) + { + for( BOARD_CONNECTED_ITEM* item : static_cast( clipItem )->AllConnectedItems() ) + item->SetNet( NETINFO_LIST::OrphanedItem() ); + } + else + static_cast( clipItem )->MapNets( m_frame->GetBoard() ); + } + // The clipboard can contain two different things, an entire kicad_pcb // or a single module @@ -667,6 +675,7 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent ) for( auto item : clipModule->GraphicalItems() ) { + item->Move( clipModule->GetPosition() ); item->SetParent( editModule ); pastedItems.push_back( item ); }