From 37f23fa5372626c6c5ef7999ba71200678e63690 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 3 Nov 2019 16:09:23 +0000 Subject: [PATCH] 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 --- pcbnew/kicad_clipboard.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index d24f2db5ee..632a9c1e26 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -97,13 +97,16 @@ void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected ) // make the module safe to transfer to other pcbs const MODULE* mod = static_cast( aSelected.Front() ); // Do not modify existing board - MODULE newModule(*mod); + MODULE newModule( *mod ); for( D_PAD* pad = newModule.PadsList().begin(); pad; pad = pad->Next() ) { pad->SetNetCode( 0, 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 +117,15 @@ void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected ) { for( const auto item : aSelected ) { - auto clone = static_cast( item->Clone() ); + BOARD_ITEM* clone = static_cast( item->Clone() ); // Do not add reference/value - convert them to the common type if( TEXTE_MODULE* text = dyn_cast( 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( clone ); - pad->SetNetCode( 0, 0 ); - } + if( D_PAD* pad = dyn_cast( 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 +172,12 @@ void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected ) auto item = static_cast( i ); std::unique_ptr clone( static_cast ( item->Clone() ) ); + // locked means "locked in place"; copied items therefore can't be locked + if( MODULE* module = dyn_cast( clone.get() ) ) + module->SetLocked( false ); + else if( TRACK* track = dyn_cast( clone.get() ) ) + track->SetLocked( false ); + // locate the reference point at (0, 0) in the copied items clone->Move( wxPoint(-refPoint.x, -refPoint.y ) );