From 38bd4b07e4534b7b0475945e999ce569e1d1c058 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Sun, 7 Nov 2021 20:50:54 +0100 Subject: [PATCH] Close the simulator before changing schematic Fixes https://gitlab.com/kicad/code/kicad/issues/9501 --- eeschema/files-io.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 6de336a43e..663f269f0b 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -1247,6 +1248,13 @@ bool SCH_EDIT_FRAME::AskToSaveChanges() // Save any currently open and modified project files. for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() ) { + SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false ); + + // Simulator must be closed before loading another schematic, otherwise it may crash. + // If there are any changes in the simulator the user will be prompted to save them. + if( simFrame && !simFrame->Close() ) + return false; + if( screen->IsContentModified() ) { if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. "