DIALOG_UNUSED_PAD_LAYERS: do not use TransferDataFromWindow for any button.

TransferDataFromWindow is called only when closing by a wxID_OK button
Fixes #13865
https://gitlab.com/kicad/code/kicad/issues/13865
This commit is contained in:
jean-pierre charras 2023-02-13 10:26:46 +01:00
parent 2cc3d8e9bc
commit 17059971e8
5 changed files with 28 additions and 11 deletions

View File

@ -76,11 +76,19 @@ void DIALOG_UNUSED_PAD_LAYERS::syncImages( wxCommandEvent& aEvent )
void DIALOG_UNUSED_PAD_LAYERS::onApply( wxCommandEvent& event )
{
updatePadsAndVias( false );
EndModal( wxID_APPLY );
}
bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow()
void DIALOG_UNUSED_PAD_LAYERS::onOK( wxCommandEvent& event )
{
updatePadsAndVias( true ); // called only with wxID_OK
event.Skip();
}
void DIALOG_UNUSED_PAD_LAYERS::updatePadsAndVias( bool aRemoveLayers )
{
if( m_cbSelectedOnly->IsChecked() )
{
@ -91,7 +99,7 @@ bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow()
if( item->Type() == PCB_VIA_T && m_cbVias->IsChecked() )
{
PCB_VIA* via = static_cast<PCB_VIA*>( item );
via->SetRemoveUnconnected( GetReturnCode() == wxID_OK );
via->SetRemoveUnconnected( aRemoveLayers );
via->SetKeepStartEnd( m_cbPreservePads->IsChecked() );
}
@ -101,7 +109,7 @@ bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow()
for( PAD* pad : footprint->Pads() )
{
pad->SetRemoveUnconnected( GetReturnCode() == wxID_OK );
pad->SetRemoveUnconnected( aRemoveLayers );
pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
}
}
@ -110,7 +118,7 @@ bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow()
{
PAD* pad = static_cast<PAD*>( item );
pad->SetRemoveUnconnected( GetReturnCode() == wxID_OK );
pad->SetRemoveUnconnected( aRemoveLayers );
pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
}
}
@ -125,7 +133,7 @@ bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow()
for( PAD* pad : footprint->Pads() )
{
pad->SetRemoveUnconnected( GetReturnCode() == wxID_OK );
pad->SetRemoveUnconnected( aRemoveLayers );
pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
}
}
@ -140,12 +148,11 @@ bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow()
m_commit.Modify( item );
PCB_VIA* via = static_cast<PCB_VIA*>( item );
via->SetRemoveUnconnected( GetReturnCode() == wxID_OK );
via->SetRemoveUnconnected( aRemoveLayers );
via->SetKeepStartEnd( m_cbPreservePads->IsChecked() );
}
}
}
m_commit.Push( _( "Set Unused Pad Properties" ) );
return true;
}

View File

@ -39,11 +39,17 @@ public:
COMMIT& aCommit );
private:
bool TransferDataFromWindow() override;
void updateImage();
/**
* Update layers of pads and vias
* aRemoveLayers = true to remove not connected layers
* false to set all layers to active
*/
void updatePadsAndVias( bool aRemoveLayers );
void onApply( wxCommandEvent& event ) override;
void onOK( wxCommandEvent& event ) override;
void syncImages( wxCommandEvent& aEvent ) override;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -80,6 +80,7 @@ DIALOG_UNUSED_PAD_LAYERS_BASE::DIALOG_UNUSED_PAD_LAYERS_BASE( wxWindow* parent,
m_cbPads->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this );
m_cbPreservePads->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this );
m_StdButtonsApply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::onApply ), NULL, this );
m_StdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::onOK ), NULL, this );
}
DIALOG_UNUSED_PAD_LAYERS_BASE::~DIALOG_UNUSED_PAD_LAYERS_BASE()
@ -89,5 +90,6 @@ DIALOG_UNUSED_PAD_LAYERS_BASE::~DIALOG_UNUSED_PAD_LAYERS_BASE()
m_cbPads->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this );
m_cbPreservePads->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this );
m_StdButtonsApply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::onApply ), NULL, this );
m_StdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::onOK ), NULL, this );
}

View File

@ -458,6 +458,7 @@
<property name="name">m_StdButtons</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick">onApply</event>
<event name="OnOKButtonClick">onOK</event>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -50,6 +50,7 @@ class DIALOG_UNUSED_PAD_LAYERS_BASE : public DIALOG_SHIM
// Virtual event handlers, override them in your derived class
virtual void syncImages( wxCommandEvent& event ) { event.Skip(); }
virtual void onApply( wxCommandEvent& event ) { event.Skip(); }
virtual void onOK( wxCommandEvent& event ) { event.Skip(); }
public: