When copying an item it's no longer at the original location and so can't be "locked".
Fixes: lp:1851038 * https://bugs.launchpad.net/kicad/+bug/1851038
This commit is contained in:
parent
1c153c55c0
commit
fae86d4dd0
|
@ -97,12 +97,13 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected )
|
|||
// make the module safe to transfer to other pcbs
|
||||
const MODULE* mod = static_cast<MODULE*>( aSelected.Front() );
|
||||
// Do not modify existing board
|
||||
MODULE newModule(*mod);
|
||||
MODULE newModule( *mod );
|
||||
|
||||
for( auto pad : newModule.Pads() )
|
||||
{
|
||||
pad->SetNetCode( 0, 0 );
|
||||
}
|
||||
for( D_PAD* pad : newModule.Pads() )
|
||||
pad->SetNetCode( 0 );
|
||||
|
||||
// locked means "locked in place"; copied items therefore can't be locked
|
||||
newModule.SetLocked( false );
|
||||
|
||||
// locate the reference point at (0, 0) in the copied items
|
||||
newModule.Move( wxPoint( -refPoint.x, -refPoint.y ) );
|
||||
|
@ -114,18 +115,15 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected )
|
|||
{
|
||||
for( const auto item : aSelected )
|
||||
{
|
||||
auto clone = static_cast<BOARD_ITEM*>( item->Clone() );
|
||||
BOARD_ITEM* clone = static_cast<BOARD_ITEM*>( item->Clone() );
|
||||
|
||||
// Do not add reference/value - convert them to the common type
|
||||
if( TEXTE_MODULE* text = dyn_cast<TEXTE_MODULE*>( clone ) )
|
||||
text->SetType( TEXTE_MODULE::TEXT_is_DIVERS );
|
||||
|
||||
// If it is only a module, clear the nets from the pads
|
||||
if( clone->Type() == PCB_PAD_T )
|
||||
{
|
||||
D_PAD* pad = static_cast<D_PAD*>( clone );
|
||||
pad->SetNetCode( 0, 0 );
|
||||
}
|
||||
if( D_PAD* pad = dyn_cast<D_PAD*>( clone ) )
|
||||
pad->SetNetCode( 0 );
|
||||
|
||||
// Add the pad to the new module before moving to ensure the local coords are correct
|
||||
partialModule.Add( clone );
|
||||
|
@ -172,6 +170,12 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected )
|
|||
auto item = static_cast<BOARD_ITEM*>( i );
|
||||
std::unique_ptr<BOARD_ITEM> clone( static_cast<BOARD_ITEM*> ( item->Clone() ) );
|
||||
|
||||
// locked means "locked in place"; copied items therefore can't be locked
|
||||
if( MODULE* module = dyn_cast<MODULE*>( clone.get() ) )
|
||||
module->SetLocked( false );
|
||||
else if( TRACK* track = dyn_cast<TRACK*>( clone.get() ) )
|
||||
track->SetLocked( false );
|
||||
|
||||
// locate the reference point at (0, 0) in the copied items
|
||||
clone->Move( (wxPoint) -refPoint );
|
||||
|
||||
|
|
Loading…
Reference in New Issue