From c30102cd4fad528d5c570a6b6e40b565b1259b7f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 1 May 2021 21:38:11 +0100 Subject: [PATCH] Don't crash when trying to save sim settings during shutdown. Fixes https://gitlab.com/kicad/code/kicad/issues/8327 --- eeschema/sch_edit_frame.cpp | 4 ++++ eeschema/sim/sim_plot_frame.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 8a12d4a1ae..c439b15fca 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -680,6 +681,9 @@ void SCH_EDIT_FRAME::doCloseWindow() if( FindHierarchyNavigator() ) FindHierarchyNavigator()->Close( true ); + if( Kiway().Player( FRAME_SIMULATOR, false ) ) + Prj().GetProjectFile().m_SchematicSettings->m_NgspiceSimulatorSettings->SaveToFile(); + SCH_SCREENS screens( Schematic().Root() ); wxFileName fn; diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 258f316aeb..d7e9f566f7 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -274,12 +274,15 @@ void SIM_PLOT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) cfg->m_Simulator.white_background = m_plotUseWhiteBg; } - if( m_schematicFrame ) + if( !m_isNonUserClose ) // If we're exiting the project has already been released. { PROJECT_FILE& project = Prj().GetProjectFile(); - project.m_SchematicSettings->m_NgspiceSimulatorSettings->SaveToFile(); - m_schematicFrame->SaveProjectSettings(); + if( project.m_SchematicSettings ) + project.m_SchematicSettings->m_NgspiceSimulatorSettings->SaveToFile(); + + if( m_schematicFrame ) + m_schematicFrame->SaveProjectSettings(); } }