From 3a35a5d5f8d5ead7c25d995e1a4fc2c746164ac8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 10 Nov 2020 22:07:30 +0000 Subject: [PATCH] Make use of polymorphism for locking/unlocking. Fixes https://gitlab.com/kicad/code/kicad/issues/6350 --- .../dialogs/dialog_track_via_properties.cpp | 2 +- pcbnew/kicad_clipboard.cpp | 9 ++------ pcbnew/pcb_edit_frame.cpp | 23 ------------------- pcbnew/pcb_edit_frame.h | 2 -- 4 files changed, 3 insertions(+), 33 deletions(-) diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index e01b53f88f..368f6b48c1 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -433,7 +433,7 @@ bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow() bool changeLock = m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED; bool setLock = m_lockedCbox->Get3StateValue() == wxCHK_CHECKED; - for( auto item : m_items ) + for( EDA_ITEM* item : m_items ) { m_commit.Modify( item ); diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 2d9572ac7e..522749833a 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -215,14 +215,9 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE copy = static_cast( item->Clone() ); } - auto prepItem = [&]( BOARD_ITEM* titem ) + auto prepItem = [&]( BOARD_ITEM* aItem ) { - // locked means "locked in place"; copied items therefore can't - // be locked - if( MODULE* footprint = dyn_cast( titem ) ) - footprint->SetLocked( false ); - else if( TRACK* track = dyn_cast( titem ) ) - track->SetLocked( false ); + aItem->SetLocked( false ); }; if( copy ) diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 144400e47d..2d778248f4 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1601,29 +1601,6 @@ void PCB_EDIT_FRAME::ProjectChanged() } -void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked ) -{ - const wxString ModulesMaskSelection = wxT( "*" ); - if( aModule ) - { - aModule->SetLocked( aLocked ); - SetMsgPanel( aModule ); - OnModify(); - } - else - { - for( auto mod : GetBoard()->Modules() ) - { - if( WildCompareString( ModulesMaskSelection, mod->GetReference() ) ) - { - mod->SetLocked( aLocked ); - OnModify(); - } - } - } -} - - bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath ); diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 01bd4efe26..c36f906f1d 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -850,8 +850,6 @@ public: void ScriptingConsoleEnableDisable(); #endif - void LockModule( MODULE* aModule, bool aLocked ); - /** * Function SendMessageToEESCHEMA * sends a message to the schematic editor so that it may move its cursor