diff --git a/eeschema/sim/simulator_frame.cpp b/eeschema/sim/simulator_frame.cpp index a20a39615b..81dbe763ff 100644 --- a/eeschema/sim/simulator_frame.cpp +++ b/eeschema/sim/simulator_frame.cpp @@ -350,6 +350,22 @@ void SIMULATOR_FRAME::UpdateTitle() } +// Don't let the dialog grow too tall: you may not be able to get to the OK button +#define MAX_MESSAGES 20 + +void SIMULATOR_FRAME::showNetlistErrors( const wxString& aErrors ) +{ + wxArrayString lines = wxSplit( aErrors, '\n' ); + + if( lines.size() > MAX_MESSAGES ) + { + lines.RemoveAt( MAX_MESSAGES, lines.size() - MAX_MESSAGES ); + lines.Add( wxS( "..." ) ); + } + + DisplayErrorMessage( this, _( "Errors during netlist generation." ), wxJoin( lines, '\n' ) ); +} + bool SIMULATOR_FRAME::LoadSimulator( const wxString& aSimCommand, unsigned aSimOptions ) { @@ -365,7 +381,7 @@ bool SIMULATOR_FRAME::LoadSimulator( const wxString& aSimCommand, unsigned aSimO if( !m_simulator->Attach( m_circuitModel, aSimCommand, aSimOptions, Prj().GetProjectPath(), s_reporter ) ) { - DisplayErrorMessage( this, _( "Errors during netlist generation.\n\n" ) + s_errors ); + showNetlistErrors( s_errors ); return false; } @@ -375,10 +391,12 @@ bool SIMULATOR_FRAME::LoadSimulator( const wxString& aSimCommand, unsigned aSimO void SIMULATOR_FRAME::ReloadSimulator( const wxString& aSimCommand, unsigned aSimOptions ) { + s_errors.clear(); + if( !m_simulator->Attach( m_circuitModel, aSimCommand, aSimOptions, Prj().GetProjectPath(), s_reporter ) ) { - DisplayErrorMessage( this, _( "Errors during netlist generation.\n\n" ) + s_errors ); + showNetlistErrors( s_errors ); } } @@ -570,8 +588,7 @@ bool SIMULATOR_FRAME::EditAnalysis() if( !m_circuitModel->ReadSchematicAndLibraries( NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS, s_reporter ) ) { - DisplayErrorMessage( this, _( "Errors during netlist generation.\n\n" ) - + s_errors ); + showNetlistErrors( s_errors ); } dlg.SetSimCommand( simTab->GetSimCommand() ); diff --git a/eeschema/sim/simulator_frame.h b/eeschema/sim/simulator_frame.h index 39dc92c6d0..01655fb79b 100644 --- a/eeschema/sim/simulator_frame.h +++ b/eeschema/sim/simulator_frame.h @@ -196,6 +196,8 @@ private: void setupUIConditions() override; + void showNetlistErrors( const wxString& aErrors ); + bool canCloseWindow( wxCloseEvent& aEvent ) override; void doCloseWindow() override;