From e450258c0fdf827563f48cf7e955cacff0872e86 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 22 Jun 2024 11:33:31 +0100 Subject: [PATCH] Show footprint change/update immediately. Also, don't deselect selected footprints. Fixes https://gitlab.com/kicad/code/kicad/-/issues/18248 --- pcbnew/dialogs/dialog_exchange_footprints.cpp | 17 ++++++++++++----- pcbnew/dialogs/dialog_exchange_footprints.h | 2 ++ pcbnew/tools/global_edit_tool.cpp | 17 +++++++---------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index 86b1724832..22bb87b9ec 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include #define ID_MATCH_FP_ALL 4200 @@ -297,19 +299,21 @@ void DIALOG_EXCHANGE_FOOTPRINTS::OnMatchIDClicked( wxCommandEvent& event ) void DIALOG_EXCHANGE_FOOTPRINTS::OnOKClicked( wxCommandEvent& event ) { - wxBusyCursor dummy; + PCB_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool(); + wxBusyCursor dummy; m_MessageWindow->Clear(); m_MessageWindow->Flush( false ); + m_newFootprints.clear(); processMatchingFootprints(); - - m_parent->Compile_Ratsnest( true ); - m_parent->GetCanvas()->Refresh(); + m_commit.Push( m_updateMode ? _( "Update Footprint" ) : _( "Change Footprint" ) ); + selTool->AddItemsToSel( &m_newFootprints ); m_MessageWindow->Flush( false ); - m_commit.Push( wxT( "Changed footprint" ) ); + WINDOW_THAWER thawer( m_parent ); + m_parent->GetCanvas()->Refresh(); } @@ -394,6 +398,9 @@ void DIALOG_EXCHANGE_FOOTPRINTS::processFootprint( FOOTPRINT* aFootprint, const if( aFootprint == m_currentFootprint ) m_currentFootprint = newFootprint; + if( newFootprint ) + m_newFootprints.push_back( newFootprint ); + if( m_updateMode && !updated ) { msg += _( ": (no changes)" ); diff --git a/pcbnew/dialogs/dialog_exchange_footprints.h b/pcbnew/dialogs/dialog_exchange_footprints.h index 21e933d481..0546c60f2f 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.h +++ b/pcbnew/dialogs/dialog_exchange_footprints.h @@ -56,9 +56,11 @@ private: void processMatchingFootprints(); void processFootprint( FOOTPRINT* aFootprint, const LIB_ID& aNewFPID ); +private: BOARD_COMMIT m_commit; PCB_EDIT_FRAME* m_parent; FOOTPRINT* m_currentFootprint; + EDA_ITEMS m_newFootprints; bool m_updateMode; int* m_matchMode; }; diff --git a/pcbnew/tools/global_edit_tool.cpp b/pcbnew/tools/global_edit_tool.cpp index 644a1439cf..ed41af586c 100644 --- a/pcbnew/tools/global_edit_tool.cpp +++ b/pcbnew/tools/global_edit_tool.cpp @@ -62,10 +62,11 @@ bool GLOBAL_EDIT_TOOL::Init() int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent ) { - PCB_SELECTION& selection = m_selectionTool->GetSelection(); - FOOTPRINT* footprint = nullptr; - bool updateMode = false; - bool currentMode = false; + PCB_EDIT_FRAME* editFrame = getEditFrame(); + PCB_SELECTION& selection = m_selectionTool->GetSelection(); + FOOTPRINT* footprint = nullptr; + bool updateMode = false; + bool currentMode = false; if( aEvent.HasPosition() ) selection = m_selectionTool->RequestSelection( EDIT_TOOL::FootprintFilter ); @@ -98,12 +99,8 @@ int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent ) wxFAIL_MSG( wxT( "ExchangeFootprints: unexpected action" ) ); } - // invoke the exchange dialog process - { - PCB_EDIT_FRAME* editFrame = getEditFrame(); - DIALOG_EXCHANGE_FOOTPRINTS dialog( editFrame, footprint, updateMode, currentMode ); - dialog.ShowQuasiModal(); - } + DIALOG_EXCHANGE_FOOTPRINTS dialog( editFrame, footprint, updateMode, currentMode ); + dialog.ShowQuasiModal(); return 0; }