From 8069e5d5d6ac84e45fe5dddf030bc0bfc913ab54 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 23 Dec 2022 18:20:20 +0000 Subject: [PATCH] Fix sim bug running a command the first time when no command in doc. Fixes https://gitlab.com/kicad/code/kicad/issues/11366 --- eeschema/sim/sim_plot_frame.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 006e08f87a..ea26a0cbd3 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -1511,20 +1511,25 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event ) const wxString& newCommand = dlg.GetSimCommand(); SIM_TYPE newSimType = NGSPICE_CIRCUIT_MODEL::CommandToSimType( newCommand ); - // If it is a new simulation type, open a new plot - // For the DC sim, check if sweep source type has changed (char 4 will contain 'v', - // 'i', 'r' or 't'. - if( !plotPanelWindow - || ( plotPanelWindow && plotPanelWindow->GetType() != newSimType ) - || ( newSimType == ST_DC - && oldCommand.Lower().GetChar( 4 ) != newCommand.Lower().GetChar( 4 ) ) ) + if( !plotPanelWindow ) + { + m_circuitModel->SetSimCommandOverride( newCommand ); + plotPanelWindow = NewPlotPanel( newCommand ); + } + // If it is a new simulation type, open a new plot. For the DC sim, check if sweep + // source type has changed (char 4 will contain 'v', 'i', 'r' or 't'. + else if( plotPanelWindow->GetType() != newSimType + || ( newSimType == ST_DC + && oldCommand.Lower().GetChar( 4 ) != newCommand.Lower().GetChar( 4 ) ) ) { plotPanelWindow = NewPlotPanel( newCommand ); } else { + if( m_workbook->GetPageIndex( plotPanelWindow ) == 0 ) + m_circuitModel->SetSimCommandOverride( newCommand ); + // Update simulation command in the current plot - m_circuitModel->SetSimCommandOverride( newCommand ); m_workbook->SetSimCommand( plotPanelWindow, newCommand ); }