From 7d79bebcc676fa2233270180f211d8e43f6493ea Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 24 Jun 2024 22:47:42 +0100 Subject: [PATCH] Don't overload error dialog. Fixes https://gitlab.com/kicad/code/kicad/-/issues/18195 (cherry picked from commit 441da8dfb62d81e19c24b48598b99dba58156623) --- eeschema/sim/simulator_frame.cpp | 25 +++++++++++++++++++++---- eeschema/sim/simulator_frame.h | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/eeschema/sim/simulator_frame.cpp b/eeschema/sim/simulator_frame.cpp index 211f575e83..f9ca474e68 100644 --- a/eeschema/sim/simulator_frame.cpp +++ b/eeschema/sim/simulator_frame.cpp @@ -340,6 +340,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 ) { @@ -355,7 +371,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; } @@ -365,10 +381,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 ); } } @@ -560,8 +578,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 4da48bbcf5..2c557ad7ef 100644 --- a/eeschema/sim/simulator_frame.h +++ b/eeschema/sim/simulator_frame.h @@ -194,6 +194,8 @@ private: void setupUIConditions() override; + void showNetlistErrors( const wxString& aErrors ); + bool canCloseWindow( wxCloseEvent& aEvent ) override; void doCloseWindow() override;