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
|
// make the module safe to transfer to other pcbs
|
||||||
const MODULE* mod = static_cast<MODULE*>( aSelected.Front() );
|
const MODULE* mod = static_cast<MODULE*>( aSelected.Front() );
|
||||||
// Do not modify existing board
|
// Do not modify existing board
|
||||||
MODULE newModule(*mod);
|
MODULE newModule( *mod );
|
||||||
|
|
||||||
for( auto pad : newModule.Pads() )
|
for( D_PAD* pad : newModule.Pads() )
|
||||||
{
|
pad->SetNetCode( 0 );
|
||||||
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
|
// locate the reference point at (0, 0) in the copied items
|
||||||
newModule.Move( wxPoint( -refPoint.x, -refPoint.y ) );
|
newModule.Move( wxPoint( -refPoint.x, -refPoint.y ) );
|
||||||
|
@ -114,18 +115,15 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected )
|
||||||
{
|
{
|
||||||
for( const auto item : 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
|
// Do not add reference/value - convert them to the common type
|
||||||
if( TEXTE_MODULE* text = dyn_cast<TEXTE_MODULE*>( clone ) )
|
if( TEXTE_MODULE* text = dyn_cast<TEXTE_MODULE*>( clone ) )
|
||||||
text->SetType( TEXTE_MODULE::TEXT_is_DIVERS );
|
text->SetType( TEXTE_MODULE::TEXT_is_DIVERS );
|
||||||
|
|
||||||
// If it is only a module, clear the nets from the pads
|
// If it is only a module, clear the nets from the pads
|
||||||
if( clone->Type() == PCB_PAD_T )
|
if( D_PAD* pad = dyn_cast<D_PAD*>( clone ) )
|
||||||
{
|
pad->SetNetCode( 0 );
|
||||||
D_PAD* pad = static_cast<D_PAD*>( clone );
|
|
||||||
pad->SetNetCode( 0, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the pad to the new module before moving to ensure the local coords are correct
|
// Add the pad to the new module before moving to ensure the local coords are correct
|
||||||
partialModule.Add( clone );
|
partialModule.Add( clone );
|
||||||
|
@ -172,6 +170,12 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected )
|
||||||
auto item = static_cast<BOARD_ITEM*>( i );
|
auto item = static_cast<BOARD_ITEM*>( i );
|
||||||
std::unique_ptr<BOARD_ITEM> clone( static_cast<BOARD_ITEM*> ( item->Clone() ) );
|
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
|
// locate the reference point at (0, 0) in the copied items
|
||||||
clone->Move( (wxPoint) -refPoint );
|
clone->Move( (wxPoint) -refPoint );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue