From 0dac0c9a4791f2b0175210fbc346b293be80a484 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sat, 4 Apr 2020 12:41:45 +0100 Subject: [PATCH] Cleanup some dynamic casts From Coverity scan --- eeschema/eeschema_config.cpp | 2 ++ pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp | 20 ++++++++++++++------ pcbnew/footprint_viewer_frame.cpp | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 7f840672f6..bdd33fa8c5 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -395,6 +395,8 @@ void SCH_EDIT_FRAME::AddFormattingParameters( std::vector& params ) { EESCHEMA_SETTINGS* appSettings = dynamic_cast( Kiface().KifaceSettings() ); + wxCHECK( appSettings, /*void*/ ); + params.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ), LIB_PART::SubpartIdSeparatorPtr(), 0, 0, 126 ) ); params.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ), diff --git a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp index 73eb70e5ad..3c92920050 100644 --- a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp +++ b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp @@ -1405,7 +1405,10 @@ void ALTIUM_PCB::ParseArcs6Data( if( elem.component != ALTIUM_COMPONENT_NONE ) { - dynamic_cast( ds )->SetLocalCoord(); + auto em = dynamic_cast( ds ); + + if( em ) + em->SetLocalCoord(); } } } @@ -1842,16 +1845,21 @@ void ALTIUM_PCB::ParseTexts6Data( itm->SetPosition( elem.position ); tx->SetTextAngle( elem.rotation * 10. ); + if( elem.component != ALTIUM_COMPONENT_NONE ) { TEXTE_MODULE* txm = dynamic_cast( tx ); - if( elem.isDesignator || elem.isComment ) + + if( txm ) { - double orientation = - static_cast( txm->GetParent() )->GetOrientation(); - txm->SetTextAngle( orientation + txm->GetTextAngle() ); + if( elem.isDesignator || elem.isComment ) + { + double orientation = + static_cast( txm->GetParent() )->GetOrientation(); + txm->SetTextAngle( orientation + txm->GetTextAngle() ); + } + txm->SetLocalCoord(); } - txm->SetLocalCoord(); } PCB_LAYER_ID klayer = GetKicadLayer( elem.layer ); diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index c549bab1f9..8c2dbcc89d 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -695,7 +695,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent ) void FOOTPRINT_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { auto cfg = dynamic_cast( aCfg ); - wxASSERT( cfg ); + wxCHECK( cfg, /*void*/ ); PCB_BASE_FRAME::LoadSettings( aCfg );