Cleanup redundant type casting

This commit is contained in:
Ian McInerney 2020-01-13 14:00:45 +00:00
parent b6f64815f4
commit e2853862e5
3 changed files with 7 additions and 11 deletions

View File

@ -280,14 +280,11 @@ static void selectAllInTextCtrls( wxWindowList& children )
{
for( wxWindow* child : children )
{
wxTextCtrl* childTextCtrl = dynamic_cast<wxTextCtrl*>( child );
if( childTextCtrl )
if( auto childTextCtrl = dynamic_cast<wxTextCtrl*>( child ) )
{
wxTextEntry* asTextEntry = dynamic_cast<wxTextEntry*>( childTextCtrl );
// Respect an existing selection
if( asTextEntry->GetStringSelection().IsEmpty() )
asTextEntry->SelectAll();
if( childTextCtrl->GetStringSelection().IsEmpty() )
childTextCtrl->SelectAll();
}
else
selectAllInTextCtrls( child->GetChildren() );

View File

@ -587,10 +587,10 @@ wxString PANEL_SETUP_LAYERS::GetLayerName( LAYER_NUM aLayer )
{
wxControl* control = getName( aLayer );
if( dynamic_cast<wxTextCtrl*>( control ) )
return static_cast<wxTextCtrl*>( control )->GetValue().Trim();
if( auto textCtl = dynamic_cast<wxTextCtrl*>( control ) )
return textCtl->GetValue().Trim();
else
return static_cast<wxStaticText*>( control )->GetLabel();
return control->GetLabel();
}

View File

@ -1046,9 +1046,8 @@ int PCBNEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
m_frame->SetMsgPanel( msgItems );
}
else if( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
else if( auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
{
FOOTPRINT_EDIT_FRAME* editFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( m_frame );
MODULE* footprint = (MODULE*) editFrame->GetModel();
if( !footprint )