diff --git a/lib/logger.h b/lib/logger.h index c2921b87..1da2e601 100644 --- a/lib/logger.h +++ b/lib/logger.h @@ -13,6 +13,9 @@ struct ErrorLogMessage std::string message; }; +struct EmergencyStopMessage +{}; + struct BeginSpeedOperationLogMessage { }; @@ -73,6 +76,7 @@ class TrackFlux; typedef std::variantBind(wxEVT_BUTTON, [this](auto&) { - auto* event = new wxCommandEvent(UPDATE_STATE_EVENT, 0); + auto* event = new wxCommandEvent(PROGRESSBAR_STOP_EVENT, 0); event->SetEventObject(this); QueueEvent(event); }); diff --git a/src/gui/main.cc b/src/gui/main.cc index a81780dc..23127e77 100644 --- a/src/gui/main.cc +++ b/src/gui/main.cc @@ -65,7 +65,7 @@ wxThread::ExitCode FluxEngineApp::Entry() } catch (const EmergencyStopException& e) { - Logger() << "Emergency stop!\n"; + Logger() << EmergencyStopMessage(); } runOnUiThread( diff --git a/src/gui/mainwindow.cc b/src/gui/mainwindow.cc index 4cc33ab9..dfbd905d 100644 --- a/src/gui/mainwindow.cc +++ b/src/gui/mainwindow.cc @@ -123,6 +123,12 @@ public: UpdateState(); CreateStatusBar(); + + _statusBar->Bind(PROGRESSBAR_STOP_EVENT, + [this](auto&) + { + emergencyStop = true; + }); } void OnExit(wxCommandEvent& event) @@ -172,11 +178,6 @@ public: UpdateState(); } - void OnStopButton(wxCommandEvent&) - { - emergencyStop = true; - } - void OnReadButton(wxCommandEvent&) { try @@ -478,11 +479,23 @@ public: { }, + /* We terminated due to the stop button. */ + [&](const EmergencyStopMessage& m) + { + _statusBar->SetLeftLabel("Emergency stop!"); + _statusBar->HideProgressBar(); + _statusBar->SetRightLabel(""); + _state = _errorState; + UpdateState(); + }, + /* A fatal error. */ [&](const ErrorLogMessage& m) { _statusBar->SetLeftLabel(m.message); wxMessageBox(m.message, "Error", wxOK | wxICON_ERROR); + _statusBar->HideProgressBar(); + _statusBar->SetRightLabel(""); _state = _errorState; UpdateState(); },