From 36f6b4a9b44a45f073ed98894dae74d8ec1793ba Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Mon, 13 Jan 2020 01:39:08 +0000 Subject: [PATCH] Clean up redundant dynamic casts --- common/widgets/paged_dialog.cpp | 10 +++------- eeschema/dialogs/dialog_edit_component_in_lib.cpp | 4 ++-- pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp | 4 ++-- pcbnew/dialogs/panel_setup_layers.cpp | 6 +++--- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/common/widgets/paged_dialog.cpp b/common/widgets/paged_dialog.cpp index 5435f0a0d2..3b3c0e15c1 100644 --- a/common/widgets/paged_dialog.cpp +++ b/common/widgets/paged_dialog.cpp @@ -247,18 +247,14 @@ void PAGED_DIALOG::OnUpdateUI( wxUpdateUIEvent& event ) DisplayErrorMessage( this, m_errorMessage ); - auto textCtrl = dynamic_cast( ctrl ); - if( textCtrl ) + if( auto textCtrl = dynamic_cast( ctrl ) ) { - auto textEntry = dynamic_cast( textCtrl ); - textEntry->SetSelection( -1, -1 ); + textCtrl->SetSelection( -1, -1 ); textCtrl->SetFocus(); return; } - auto grid = dynamic_cast( ctrl ); - - if( grid ) + if( auto grid = dynamic_cast( ctrl ) ) { grid->SetFocus(); grid->MakeCellVisible( m_errorRow, m_errorCol ); diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index bcf960ab61..239ebe84ee 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -671,8 +671,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnUpdateUI( wxUpdateUIEvent& event ) { m_delayedFocusCtrl->SetFocus(); - if( dynamic_cast( m_delayedFocusCtrl ) ) - dynamic_cast( m_delayedFocusCtrl )->SelectAll(); + if( auto textEntry = dynamic_cast( m_delayedFocusCtrl ) ) + textEntry->SelectAll(); m_delayedFocusCtrl = nullptr; } diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index 1b48a2df73..5dd530f24e 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -834,8 +834,8 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnUpdateUI( wxUpdateUIEvent& event ) { m_delayedFocusCtrl->SetFocus(); - if( dynamic_cast( m_delayedFocusCtrl ) ) - dynamic_cast( m_delayedFocusCtrl )->SelectAll(); + if( auto textEntry = dynamic_cast( m_delayedFocusCtrl ) ) + textEntry->SelectAll(); m_delayedFocusCtrl = nullptr; } diff --git a/pcbnew/dialogs/panel_setup_layers.cpp b/pcbnew/dialogs/panel_setup_layers.cpp index d0b8ee44ad..c31316c48d 100644 --- a/pcbnew/dialogs/panel_setup_layers.cpp +++ b/pcbnew/dialogs/panel_setup_layers.cpp @@ -285,10 +285,10 @@ void PANEL_SETUP_LAYERS::showBoardLayerNames() { wxString lname = m_pcb->GetLayerName( layer ); - if( dynamic_cast( ctl ) ) - dynamic_cast( ctl )->SetValue( lname ); // wxTextCtrl + if( auto textCtl = dynamic_cast( ctl ) ) + textCtl->SetValue( lname ); // wxTextCtrl else - ctl->SetLabel( lname ); // wxStaticText + ctl->SetLabel( lname ); // wxStaticText } } }