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 ); DisplayErrorMessage( this, m_errorMessage );
auto textCtrl = dynamic_cast<wxTextCtrl*>( ctrl ); if( auto textCtrl = dynamic_cast<wxTextCtrl*>( ctrl ) )
if( textCtrl )
{ {
auto textEntry = dynamic_cast<wxTextEntry*>( textCtrl ); textCtrl->SetSelection( -1, -1 );
textEntry->SetSelection( -1, -1 );
textCtrl->SetFocus(); textCtrl->SetFocus();
return; return;
} }
auto grid = dynamic_cast<wxGrid*>( ctrl ); if( auto grid = dynamic_cast<wxGrid*>( ctrl ) )
if( grid )
{ {
grid->SetFocus(); grid->SetFocus();
grid->MakeCellVisible( m_errorRow, m_errorCol ); grid->MakeCellVisible( m_errorRow, m_errorCol );

View File

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

View File

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

View File

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