From e2853862e526087d28c2e79c54d32e8c7b536907 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Mon, 13 Jan 2020 14:00:45 +0000 Subject: [PATCH] Cleanup redundant type casting --- common/dialog_shim.cpp | 9 +++------ pcbnew/dialogs/panel_setup_layers.cpp | 6 +++--- pcbnew/tools/pcbnew_control.cpp | 3 +-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 71b6078599..8eba14f6c6 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -280,14 +280,11 @@ static void selectAllInTextCtrls( wxWindowList& children ) { for( wxWindow* child : children ) { - wxTextCtrl* childTextCtrl = dynamic_cast( child ); - if( childTextCtrl ) + if( auto childTextCtrl = dynamic_cast( child ) ) { - wxTextEntry* asTextEntry = dynamic_cast( childTextCtrl ); - // Respect an existing selection - if( asTextEntry->GetStringSelection().IsEmpty() ) - asTextEntry->SelectAll(); + if( childTextCtrl->GetStringSelection().IsEmpty() ) + childTextCtrl->SelectAll(); } else selectAllInTextCtrls( child->GetChildren() ); diff --git a/pcbnew/dialogs/panel_setup_layers.cpp b/pcbnew/dialogs/panel_setup_layers.cpp index c31316c48d..d3c9970021 100644 --- a/pcbnew/dialogs/panel_setup_layers.cpp +++ b/pcbnew/dialogs/panel_setup_layers.cpp @@ -587,10 +587,10 @@ wxString PANEL_SETUP_LAYERS::GetLayerName( LAYER_NUM aLayer ) { wxControl* control = getName( aLayer ); - if( dynamic_cast( control ) ) - return static_cast( control )->GetValue().Trim(); + if( auto textCtl = dynamic_cast( control ) ) + return textCtl->GetValue().Trim(); else - return static_cast( control )->GetLabel(); + return control->GetLabel(); } diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 96e78bfd34..c5b4f082b2 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -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( m_frame ) ) + else if( auto editFrame = dynamic_cast( m_frame ) ) { - FOOTPRINT_EDIT_FRAME* editFrame = static_cast( m_frame ); MODULE* footprint = (MODULE*) editFrame->GetModel(); if( !footprint )