Clean up redundant dynamic casts

This commit is contained in:
Ian McInerney 2020-01-13 01:39:08 +00:00
parent 94f8aafec5
commit 36f6b4a9b4
4 changed files with 10 additions and 14 deletions

View File

@ -247,18 +247,14 @@ void PAGED_DIALOG::OnUpdateUI( wxUpdateUIEvent& event )
DisplayErrorMessage( this, m_errorMessage );
auto textCtrl = dynamic_cast<wxTextCtrl*>( ctrl );
if( textCtrl )
if( auto textCtrl = dynamic_cast<wxTextCtrl*>( ctrl ) )
{
auto textEntry = dynamic_cast<wxTextEntry*>( textCtrl );
textEntry->SetSelection( -1, -1 );
textCtrl->SetSelection( -1, -1 );
textCtrl->SetFocus();
return;
}
auto grid = dynamic_cast<wxGrid*>( ctrl );
if( grid )
if( auto grid = dynamic_cast<wxGrid*>( ctrl ) )
{
grid->SetFocus();
grid->MakeCellVisible( m_errorRow, m_errorCol );

View File

@ -671,8 +671,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnUpdateUI( wxUpdateUIEvent& event )
{
m_delayedFocusCtrl->SetFocus();
if( dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl )->SelectAll();
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
textEntry->SelectAll();
m_delayedFocusCtrl = nullptr;
}

View File

@ -834,8 +834,8 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnUpdateUI( wxUpdateUIEvent& event )
{
m_delayedFocusCtrl->SetFocus();
if( dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl )->SelectAll();
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
textEntry->SelectAll();
m_delayedFocusCtrl = nullptr;
}

View File

@ -285,8 +285,8 @@ void PANEL_SETUP_LAYERS::showBoardLayerNames()
{
wxString lname = m_pcb->GetLayerName( layer );
if( dynamic_cast<wxTextCtrl*>( ctl ) )
dynamic_cast<wxTextCtrl*>( ctl )->SetValue( lname ); // wxTextCtrl
if( auto textCtl = dynamic_cast<wxTextCtrl*>( ctl ) )
textCtl->SetValue( lname ); // wxTextCtrl
else
ctl->SetLabel( lname ); // wxStaticText
}