Don't crash when trying to save sim settings during shutdown.

Fixes https://gitlab.com/kicad/code/kicad/issues/8327
This commit is contained in:
Jeff Young 2021-05-01 21:38:11 +01:00
parent 9dc611f704
commit c30102cd4f
2 changed files with 10 additions and 3 deletions

View File

@ -53,6 +53,7 @@
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <advanced_config.h> #include <advanced_config.h>
#include <sim/sim_plot_frame.h> #include <sim/sim_plot_frame.h>
#include <sim/spice_settings.h>
#include <tool/action_manager.h> #include <tool/action_manager.h>
#include <tool/action_toolbar.h> #include <tool/action_toolbar.h>
#include <tool/common_control.h> #include <tool/common_control.h>
@ -680,6 +681,9 @@ void SCH_EDIT_FRAME::doCloseWindow()
if( FindHierarchyNavigator() ) if( FindHierarchyNavigator() )
FindHierarchyNavigator()->Close( true ); FindHierarchyNavigator()->Close( true );
if( Kiway().Player( FRAME_SIMULATOR, false ) )
Prj().GetProjectFile().m_SchematicSettings->m_NgspiceSimulatorSettings->SaveToFile();
SCH_SCREENS screens( Schematic().Root() ); SCH_SCREENS screens( Schematic().Root() );
wxFileName fn; wxFileName fn;

View File

@ -274,12 +274,15 @@ void SIM_PLOT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
cfg->m_Simulator.white_background = m_plotUseWhiteBg; 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_FILE& project = Prj().GetProjectFile();
project.m_SchematicSettings->m_NgspiceSimulatorSettings->SaveToFile(); if( project.m_SchematicSettings )
m_schematicFrame->SaveProjectSettings(); project.m_SchematicSettings->m_NgspiceSimulatorSettings->SaveToFile();
if( m_schematicFrame )
m_schematicFrame->SaveProjectSettings();
} }
} }