diff --git a/common/base_screen.cpp b/common/base_screen.cpp index b664b9c81a..95807eb4e3 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -62,9 +62,8 @@ void BASE_SCREEN::InitDataPoints( const VECTOR2I& aPageSizeIU ) void BASE_SCREEN::SetPageCount( int aPageCount ) { - wxCHECK( aPageCount > 0, /* void */ ); - - m_pageCount = aPageCount; + if( aPageCount > 0 ) + m_pageCount = aPageCount; } diff --git a/common/dialogs/dialog_print_generic.cpp b/common/dialogs/dialog_print_generic.cpp index 74e0dfeaf4..c91b6e33f5 100644 --- a/common/dialogs/dialog_print_generic.cpp +++ b/common/dialogs/dialog_print_generic.cpp @@ -152,7 +152,7 @@ double DIALOG_PRINT_GENERIC::getScaleValue() if( !m_scaleCustomText->GetValue().ToDouble( &scale ) ) { - DisplayInfoMessage( nullptr, _( "Warning: Bad scale number" ) ); + DisplayInfoMessage( nullptr, _( "Warning: scale is not a number." ) ); scale = 1.0; } @@ -160,23 +160,24 @@ double DIALOG_PRINT_GENERIC::getScaleValue() { scale = MAX_SCALE; setScaleValue( scale ); - DisplayInfoMessage( nullptr, - wxString::Format( _( "Warning: Scale option set to a very large value.\n" - " Clamped to %f" ), scale ) ); + DisplayInfoMessage( nullptr, wxString::Format( _( "Warning: scale set to a very large " + "value.\nIt will be clamped to %f." ), + scale ) ); } else if( scale < MIN_SCALE ) { scale = MIN_SCALE; setScaleValue( scale ); - DisplayInfoMessage( nullptr, - wxString::Format( _( "Warning: Scale option set to a very small value.\n" - " Clamped to %f" ), scale ) ); + DisplayInfoMessage( nullptr, wxString::Format( _( "Warning: scale set to a very small " + "value.\nIt will be clamped to %f." ), + scale ) ); } return scale; } - wxCHECK( false, 1.0 ); + wxFAIL_MSG( wxT( "No scale option selected." ) ); + return 1.0; } diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 510c934ae4..a870b2d7fd 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -1244,7 +1244,8 @@ bool TOOL_MANAGER::IsToolActive( TOOL_ID aId ) const { auto it = m_toolIdIndex.find( aId ); - wxCHECK( it != m_toolIdIndex.end(), false ); + if( it == m_toolIdIndex.end() ) + return false; return !it->second->idle; } diff --git a/common/widgets/properties_panel.cpp b/common/widgets/properties_panel.cpp index b69dbd9a4e..c670fefb23 100644 --- a/common/widgets/properties_panel.cpp +++ b/common/widgets/properties_panel.cpp @@ -199,7 +199,7 @@ void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection ) for( EDA_ITEM* item : aSelection ) types.insert( TYPE_HASH( *item ) ); - wxCHECK( !types.empty(), /* void */ ); + wxCHECK( !types.empty(), /* void */ ); // already guarded above, but Coverity doesn't know that PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); std::set commonProps; diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 78ca545313..97d790f0b9 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -435,14 +435,13 @@ void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent ) bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aInstance ) { - LIB_ID id; - - wxCHECK( aSymbol, false ); - SCH_EDIT_FRAME* frame = dynamic_cast( GetParent() ); wxCHECK( frame, false ); + if( !aSymbol ) + return false; + if( m_matchAll->GetValue() ) { return true; @@ -465,6 +464,8 @@ bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aInsta } else if( m_matchById ) { + LIB_ID id; + id.Parse( getLibIdValue( m_specifiedId ) ); return aSymbol->GetLibId() == id; } diff --git a/eeschema/dialogs/dialog_eeschema_page_settings.cpp b/eeschema/dialogs/dialog_eeschema_page_settings.cpp index fa6d32dc4f..ede8e9b474 100644 --- a/eeschema/dialogs/dialog_eeschema_page_settings.cpp +++ b/eeschema/dialogs/dialog_eeschema_page_settings.cpp @@ -35,7 +35,7 @@ DIALOG_EESCHEMA_PAGE_SETTINGS::DIALOG_EESCHEMA_PAGE_SETTINGS( EDA_DRAW_FRAME* aP DIALOG_EESCHEMA_PAGE_SETTINGS::~DIALOG_EESCHEMA_PAGE_SETTINGS() { - auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); wxCHECK( cfg, /* void */ ); cfg->m_PageSettings.export_paper = m_PaperExport->GetValue(); @@ -85,7 +85,7 @@ void DIALOG_EESCHEMA_PAGE_SETTINGS::onTransferDataToWindow() msg.Printf( format, m_screen->GetVirtualPageNumber() ); m_TextSheetNumber->SetLabel( msg ); - auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); wxCHECK( cfg, /* void */ ); m_PaperExport->SetValue( cfg->m_PageSettings.export_paper ); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index 73750f43a3..891d31d7a0 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -246,15 +246,16 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow() symbolNames.Remove( m_libEntry->GetName() ); m_inheritanceSelectCombo->Append( symbolNames ); - LIB_SYMBOL_SPTR rootSymbol = m_libEntry->GetParent().lock(); + if( LIB_SYMBOL_SPTR rootSymbol = m_libEntry->GetParent().lock() ) + { + wxString parentName = UnescapeString( rootSymbol->GetName() ); + int selection = m_inheritanceSelectCombo->FindString( parentName ); - wxCHECK( rootSymbol, false ); + if( selection == wxNOT_FOUND ) + return false; - wxString parentName = UnescapeString( rootSymbol->GetName() ); - int selection = m_inheritanceSelectCombo->FindString( parentName ); - - wxCHECK( selection != wxNOT_FOUND, false ); - m_inheritanceSelectCombo->SetSelection( selection ); + m_inheritanceSelectCombo->SetSelection( selection ); + } m_lastOpenedPage = 0; } diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index abfce99991..1b7178353e 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -1314,14 +1314,13 @@ void DIALOG_SIM_MODEL::onPinModelComboboxTextEnter( wxCommandEvent& aEvent ) template void DIALOG_SIM_MODEL::onDifferentialCheckbox( wxCommandEvent& aEvent ) { - SIM_MODEL_IBIS* modelibis = dynamic_cast( &curModel() ); + if( SIM_MODEL_IBIS* modelibis = dynamic_cast( &curModel() ) ) + { + bool diff = m_differentialCheckbox->GetValue() && modelibis->CanDifferential(); + modelibis->SwitchSingleEndedDiff( diff ); - wxCHECK( modelibis, /* void */ ); - - bool diff = m_differentialCheckbox->GetValue() && modelibis->CanDifferential(); - modelibis->SwitchSingleEndedDiff( diff ); - - updateWidgets(); + updateWidgets(); + } } diff --git a/eeschema/netlist_exporters/netlist_exporter_base.cpp b/eeschema/netlist_exporters/netlist_exporter_base.cpp index 6e7456e341..d9b069547d 100644 --- a/eeschema/netlist_exporters/netlist_exporter_base.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_base.cpp @@ -131,7 +131,8 @@ std::vector NETLIST_EXPORTER_BASE::CreatePinList( SCH_SYMBOL* aSymbol, { std::vector pins; - wxCHECK( aSymbol, pins ); + if( !aSymbol ) + return pins; wxString ref( aSymbol->GetRef( &aSheetPath ) ); diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index 1848a0fc56..14157495e5 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -1038,22 +1038,21 @@ bool SIM_MODEL::requiresSpiceModelLine( const SPICE_ITEM& aItem ) const if ( param.value == "" ) continue; - const SIM_MODEL* baseModel = dynamic_cast( m_baseModel ); + if( const SIM_MODEL* baseModel = dynamic_cast( m_baseModel ) ) + { + const std::string& baseValue = baseModel->m_params[ii].value; - wxCHECK( baseModel, false ); + if( param.value == baseValue ) + continue; - std::string baseValue = baseModel->m_params[ii].value; + // One more check for equivalence, mostly for early 7.0 files which wrote all + // parameters to the Sim.Params field in normalized format + if( param.value == SIM_VALUE::Normalize( SIM_VALUE::ToDouble( baseValue ) ) ) + continue; - if( param.value == baseValue ) - continue; - - // One more check for equivalence, mostly for early 7.0 files which wrote all parameters - // to the Sim.Params field in normalized format - if( param.value == SIM_VALUE::Normalize( SIM_VALUE::ToDouble( baseValue ) ) ) - continue; - - // Overrides must be written - return true; + // Overrides must be written + return true; + } } return false; diff --git a/eeschema/sim/sim_property.cpp b/eeschema/sim/sim_property.cpp index 6fa4982ea7..944e5a85f5 100644 --- a/eeschema/sim/sim_property.cpp +++ b/eeschema/sim/sim_property.cpp @@ -97,52 +97,49 @@ bool SIM_STRING_PROPERTY::OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_prima { if( event.GetEventType() == wxEVT_SET_FOCUS && allowEval() ) { - wxTextEntry* textEntry = dynamic_cast( wnd_primary ); - - wxCHECK( textEntry, false ); - - wxString oldStr = m_eval.OriginalText(); - - if( oldStr.length() && oldStr != textEntry->GetValue() ) + if( wxTextEntry* textEntry = dynamic_cast( wnd_primary ) ) { - SetValueInEvent( oldStr ); - textEntry->SetValue( oldStr ); - } + wxString oldStr = m_eval.OriginalText(); - m_needsEval = true; - return true; + if( oldStr.length() && oldStr != textEntry->GetValue() ) + { + SetValueInEvent( oldStr ); + textEntry->SetValue( oldStr ); + } + + m_needsEval = true; + return true; + } } else if( event.GetEventType() == wxEVT_KILL_FOCUS && allowEval() ) { - wxTextEntry* textEntry = dynamic_cast( wnd_primary ); - - wxCHECK( textEntry, false ); - - wxString strValue = textEntry->GetValue(); - - if( !strValue.IsEmpty() && m_eval.Process( strValue ) ) + if( wxTextEntry* textEntry = dynamic_cast( wnd_primary ) ) { - double value = SIM_VALUE::ToDouble( m_eval.Result().ToStdString() ); + wxString strValue = textEntry->GetValue(); - if( std::isnan( value ) || SIM_VALUE::Equal( value, strValue.ToStdString() ) ) + if( !strValue.IsEmpty() && m_eval.Process( strValue ) ) { - // Don't mess up user formatting if eval'ing didn't actually change the value. - } - else - { - SetValueInEvent( m_eval.Result() ); + double value = SIM_VALUE::ToDouble( m_eval.Result().ToStdString() ); + + if( std::isnan( value ) || SIM_VALUE::Equal( value, strValue.ToStdString() ) ) + { + // Don't mess up user formatting if eval'ing didn't actually change the value. + } + else + { + SetValueInEvent( m_eval.Result() ); + } } + + m_needsEval = false; + return true; } - - m_needsEval = false; - return true; } else if( event.GetEventType() == wxEVT_KEY_DOWN ) { - wxKeyEvent& keyEvent = dynamic_cast( event ); - wxPropertyGrid* propGrid = dynamic_cast( wnd_primary->GetParent() ); + wxKeyEvent& keyEvent = dynamic_cast( event ); - if( propGrid ) + if( wxPropertyGrid* propGrid = dynamic_cast( wnd_primary->GetParent() ) ) { if( keyEvent.GetKeyCode() == WXK_TAB ) { diff --git a/eeschema/sim/simulator_frame_ui.cpp b/eeschema/sim/simulator_frame_ui.cpp index ff19d91e67..69a33c3930 100644 --- a/eeschema/sim/simulator_frame_ui.cpp +++ b/eeschema/sim/simulator_frame_ui.cpp @@ -591,16 +591,15 @@ void SIMULATOR_FRAME_UI::ShowChangedLanguage() { for( int ii = 0; ii < (int) m_plotNotebook->GetPageCount(); ++ii ) { - SIM_TAB* simTab = dynamic_cast( m_plotNotebook->GetPage( ii ) ); + if( SIM_TAB* simTab = dynamic_cast( m_plotNotebook->GetPage( ii ) ) ) + { + simTab->OnLanguageChanged(); - wxCHECK( simTab, /* void */ ); + wxString pageTitle( simulator()->TypeToName( simTab->GetSimType(), true ) ); + pageTitle.Prepend( wxString::Format( _( "Analysis %u - " ), ii+1 /* 1-based */ ) ); - simTab->OnLanguageChanged(); - - wxString pageTitle( simulator()->TypeToName( simTab->GetSimType(), true ) ); - pageTitle.Prepend( wxString::Format( _( "Analysis %u - " ), ii+1 /* 1-based */ ) ); - - m_plotNotebook->SetPageText( ii, pageTitle ); + m_plotNotebook->SetPageText( ii, pageTitle ); + } } m_filter->SetHint( _( "Filter" ) ); @@ -1576,25 +1575,25 @@ void SIMULATOR_FRAME_UI::AddTrace( const wxString& aName, SIM_TRACE_TYPE aType ) return; } - SIM_PLOT_TAB* plotTab = dynamic_cast( GetCurrentSimTab() ); - wxCHECK( plotTab, /* void */ ); + if( SIM_PLOT_TAB* plotTab = dynamic_cast( GetCurrentSimTab() ) ) + { + if( simType == ST_AC ) + { + updateTrace( aName, aType | SPT_AC_GAIN, plotTab ); + updateTrace( aName, aType | SPT_AC_PHASE, plotTab ); + } + else if( simType == ST_SP ) + { + updateTrace( aName, aType | SPT_AC_GAIN, plotTab ); + updateTrace( aName, aType | SPT_AC_PHASE, plotTab ); + } + else + { + updateTrace( aName, aType, plotTab ); + } - if( simType == ST_AC ) - { - updateTrace( aName, aType | SPT_AC_GAIN, plotTab ); - updateTrace( aName, aType | SPT_AC_PHASE, plotTab ); + plotTab->GetPlotWin()->UpdateAll(); } - else if( simType == ST_SP ) - { - updateTrace( aName, aType | SPT_AC_GAIN, plotTab ); - updateTrace( aName, aType | SPT_AC_PHASE, plotTab ); - } - else - { - updateTrace( aName, aType, plotTab ); - } - - plotTab->GetPlotWin()->UpdateAll(); updateSignalsGrid(); OnModify(); @@ -2099,11 +2098,8 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath ) { m_simulatorFrame->LoadSimulator( simTab->GetSimCommand(), simTab->GetSimOptions() ); - simTab = dynamic_cast( m_plotNotebook->GetPage( 0 ) ); - - wxCHECK( simTab, false ); - - simTab->SetLastSchTextSimCommand( js[ "last_sch_text_sim_command" ] ); + if( SIM_TAB* firstTab = dynamic_cast( m_plotNotebook->GetPage( 0 ) ) ) + firstTab->SetLastSchTextSimCommand( js[ "last_sch_text_sim_command" ] ); } } catch( nlohmann::json::parse_error& error )