Tidying shutdown routines
This commit is contained in:
@@ -182,19 +182,28 @@ namespace Bloom
|
|||||||
Thread::threadState = ThreadState::SHUTDOWN_INITIATED;
|
Thread::threadState = ThreadState::SHUTDOWN_INITIATED;
|
||||||
Logger::info("Shutting down Bloom");
|
Logger::info("Shutting down Bloom");
|
||||||
|
|
||||||
|
this->stopDebugServer();
|
||||||
|
this->stopTargetController();
|
||||||
|
this->stopSignalHandler();
|
||||||
|
|
||||||
|
try {
|
||||||
|
this->saveProjectSettings();
|
||||||
|
|
||||||
|
} catch (const Exception& exception) {
|
||||||
|
Logger::error("Failed to save project settings - " + exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread::threadState = ThreadState::STOPPED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::triggerShutdown() {
|
||||||
#ifndef EXCLUDE_INSIGHT
|
#ifndef EXCLUDE_INSIGHT
|
||||||
if (this->insight != nullptr) {
|
if (this->insight != nullptr) {
|
||||||
this->insight->shutdown();
|
this->insight->shutdown();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->stopDebugServer();
|
this->qtApplication.exit(EXIT_SUCCESS);
|
||||||
this->stopTargetController();
|
|
||||||
this->stopSignalHandler();
|
|
||||||
|
|
||||||
this->saveProjectSettings();
|
|
||||||
this->qtApplication.exit(0);
|
|
||||||
Thread::threadState = ThreadState::STOPPED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::loadProjectSettings() {
|
void Application::loadProjectSettings() {
|
||||||
@@ -579,26 +588,26 @@ namespace Bloom
|
|||||||
|
|
||||||
void Application::onShutdownApplicationRequest(const Events::ShutdownApplication&) {
|
void Application::onShutdownApplicationRequest(const Events::ShutdownApplication&) {
|
||||||
Logger::debug("ShutdownApplication event received.");
|
Logger::debug("ShutdownApplication event received.");
|
||||||
this->shutdown();
|
this->triggerShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::onTargetControllerThreadStateChanged(const Events::TargetControllerThreadStateChanged& event) {
|
void Application::onTargetControllerThreadStateChanged(const Events::TargetControllerThreadStateChanged& event) {
|
||||||
if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) {
|
if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) {
|
||||||
// TargetController has unexpectedly shutdown.
|
// TargetController has unexpectedly shutdown.
|
||||||
this->shutdown();
|
this->triggerShutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::onDebugServerThreadStateChanged(const Events::DebugServerThreadStateChanged& event) {
|
void Application::onDebugServerThreadStateChanged(const Events::DebugServerThreadStateChanged& event) {
|
||||||
if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) {
|
if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) {
|
||||||
// DebugServer has unexpectedly shutdown - it must have encountered a fatal error.
|
// DebugServer has unexpectedly shutdown - it must have encountered a fatal error.
|
||||||
this->shutdown();
|
this->triggerShutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::onDebugSessionFinished(const Events::DebugSessionFinished& event) {
|
void Application::onDebugSessionFinished(const Events::DebugSessionFinished& event) {
|
||||||
if (this->environmentConfig->shutdownPostDebugSession || Services::ProcessService::isManagedByClion()) {
|
if (this->environmentConfig->shutdownPostDebugSession || Services::ProcessService::isManagedByClion()) {
|
||||||
this->shutdown();
|
this->triggerShutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,10 +159,15 @@ namespace Bloom
|
|||||||
void startup();
|
void startup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will cleanly shutdown the application. This should never fail.
|
* Will cleanly shutdown the application.
|
||||||
*/
|
*/
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will trigger a clean shutdown.
|
||||||
|
*/
|
||||||
|
void triggerShutdown();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts or generates project settings.
|
* Extracts or generates project settings.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user