From df62adf90115fa1b41215c5d8bbc4227c4d614f6 Mon Sep 17 00:00:00 2001 From: Sylwester Kocjan Date: Tue, 26 Jan 2021 22:34:27 +0100 Subject: [PATCH] eeschema,sim: fix crash at simulation start fixes: https://gitlab.com/kicad/code/kicad/-/issues/7277 --- eeschema/sim/sim_plot_frame.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 929392e714..ad3bf6be8e 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -166,6 +166,12 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) m_reporter = new SIM_THREAD_REPORTER( this ); m_simulator->SetReporter( m_reporter ); + // the settings dialog will be created later, on demand. + // if created in the ctor, for some obscure reason, there is an issue + // on Windows: when open it, the simulator frame is sent to the background. + // instead of being behind the dialog frame (as it does) + m_settingsDlg = nullptr; + updateNetlistExporter(); Connect( EVT_SIM_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onSimUpdate ), NULL, this ); @@ -210,12 +216,6 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) m_welcomePanel = new SIM_PANEL_BASE( wxEmptyString, m_plotNotebook, wxID_ANY ); m_plotNotebook->AddPage( m_welcomePanel, _( "Welcome!" ), 1, true ); - // the settings dialog will be created later, on demand. - // if created in the ctor, for some obscure reason, there is an issue - // on Windows: when open it, the simulator frame is sent to the background. - // instead of being behind the dialog frame (as it does) - m_settingsDlg = NULL; - // resize the subwindows size. At least on Windows, calling wxSafeYield before // resizing the subwindows forces the wxSplitWindows size events automatically generated // by wxWidgets to be executed before our resize code. @@ -677,6 +677,8 @@ void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName, bool aErase ) void SIM_PLOT_FRAME::updateNetlistExporter() { m_exporter.reset( new NETLIST_EXPORTER_PSPICE_SIM( &m_schematicFrame->Schematic() ) ); + if( m_settingsDlg ) + m_settingsDlg->SetNetlistExporter( m_exporter.get() ); } @@ -1299,6 +1301,9 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event ) { SIM_PANEL_BASE* plotPanelWindow = currentPlotWindow(); + if( !m_settingsDlg ) + m_settingsDlg = new DIALOG_SIM_SETTINGS( this ); + // Initial processing is required to e.g. display a list of power sources updateNetlistExporter(); @@ -1308,14 +1313,9 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event ) return; } - if( !m_settingsDlg ) - m_settingsDlg = new DIALOG_SIM_SETTINGS( this ); - if( plotPanelWindow != m_welcomePanel ) m_settingsDlg->SetSimCommand( m_plots[plotPanelWindow].m_simCommand ); - m_settingsDlg->SetNetlistExporter( m_exporter.get() ); - if( m_settingsDlg->ShowModal() == wxID_OK ) { wxString oldCommand = m_plots[plotPanelWindow].m_simCommand;