From 7fbad183db0c0779ef48c5d474a3688f1bec529e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 13 Jan 2023 13:38:23 +0000 Subject: [PATCH] Gracefully handle Quit when simulator window is open. --- eeschema/sim/sim_plot_frame.cpp | 13 ++++++++++++- eeschema/sim/sim_plot_frame.h | 7 +------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 285a3700d1..0959593ff0 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -149,6 +149,8 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_circuitModel.reset( new NGSPICE_CIRCUIT_MODEL( &m_schematicFrame->Schematic() ) ); + Bind( wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME::menuExit ), this, wxID_EXIT ); + Bind( EVT_SIM_UPDATE, &SIM_PLOT_FRAME::onSimUpdate, this ); Bind( EVT_SIM_REPORT, &SIM_PLOT_FRAME::onSimReport, this ); Bind( EVT_SIM_STARTED, &SIM_PLOT_FRAME::onSimStarted, this ); @@ -1204,7 +1206,6 @@ void SIM_PLOT_FRAME::menuSaveWorkbookAs( wxCommandEvent& event ) saveWorkbook( Prj().AbsolutePath( saveAsDlg.GetPath() ) ); } - void SIM_PLOT_FRAME::menuSaveImage( wxCommandEvent& event ) { if( !GetCurrentPlot() ) @@ -1946,6 +1947,16 @@ void SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent ) } +void SIM_PLOT_FRAME::menuExit( wxCommandEvent& event ) +{ + if( event.GetId() == wxID_EXIT ) + Kiway().OnKiCadExit(); + + if( event.GetId() == wxID_CLOSE ) + Close( false ); +} + + wxDEFINE_EVENT( EVT_SIM_UPDATE, wxCommandEvent ); wxDEFINE_EVENT( EVT_SIM_REPORT, wxCommandEvent ); diff --git a/eeschema/sim/sim_plot_frame.h b/eeschema/sim/sim_plot_frame.h index 00e623a24c..f0cdcad3c1 100644 --- a/eeschema/sim/sim_plot_frame.h +++ b/eeschema/sim/sim_plot_frame.h @@ -249,12 +249,7 @@ private: void menuOpenWorkbook( wxCommandEvent& event ) override; void menuSaveWorkbook( wxCommandEvent& event ) override; void menuSaveWorkbookAs( wxCommandEvent& event ) override; - - void menuExit( wxCommandEvent& event ) override - { - Close(); - } - + void menuExit( wxCommandEvent& event ) override; void menuSaveImage( wxCommandEvent& event ) override; void menuSaveCsv( wxCommandEvent& event ) override; void menuZoomIn( wxCommandEvent& event ) override;