diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp index 31e83fa4b3..4d2c0a6f2c 100644 --- a/eeschema/sim/ngspice.cpp +++ b/eeschema/sim/ngspice.cpp @@ -282,8 +282,25 @@ bool NGSPICE::LoadNetlist( const string& aNetlist ) bool NGSPICE::Run() { - LOCALE_IO c_locale; // ngspice works correctly only with C locale - return Command( "bg_run" ); // bg_* commands execute in a separate thread + wxBusyCursor dummy; + + LOCALE_IO c_locale; // ngspice works correctly only with C locale + bool success = Command( "bg_run" ); // bg_* commands execute in a separate thread + + if( success ) + { + // wait for end of simulation. + // calling wxYield() allows printing activity, and stopping ngspice from GUI + // Also note: do not user wxSafeYield, because when using it we cannot stop + // ngspice from the GUI + do + { + wxMilliSleep( 50 ); + wxYield(); + } while( m_ngSpice_Running() ); + } + + return success; } @@ -296,7 +313,7 @@ bool NGSPICE::Stop() bool NGSPICE::IsRunning() { - LOCALE_IO c_locale; // ngspice works correctly only with C locale + // No need to use C locale here return m_ngSpice_Running(); } diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index d7e9f566f7..dd6cc22fba 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -1336,6 +1336,12 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event ) void SIM_PLOT_FRAME::onAddSignal( wxCommandEvent& event ) { + if( IsSimulationRunning() ) + { + DisplayInfoMessage( this, _( "Simulator is running. Try later" ) ); + return; + } + SIM_PLOT_PANEL* plotPanel = CurrentPlot(); if( !plotPanel || !m_exporter || plotPanel->GetType() != m_exporter->GetSimType() ) @@ -1354,6 +1360,12 @@ void SIM_PLOT_FRAME::onProbe( wxCommandEvent& event ) if( m_schematicFrame == NULL ) return; + if( IsSimulationRunning() ) + { + DisplayInfoMessage( this, _( "Simulator is running. Try later" ) ); + return; + } + m_schematicFrame->GetToolManager()->RunAction( EE_ACTIONS::simProbe ); m_schematicFrame->Raise(); }