This commit is contained in:
Nav
2022-02-09 17:49:25 +00:00
parent 56dc870b8e
commit 8d0dc68da0
3 changed files with 19 additions and 18 deletions

View File

@@ -87,7 +87,7 @@ namespace Bloom
} }
void Application::startup() { void Application::startup() {
auto applicationEventListener = this->applicationEventListener; auto& applicationEventListener = this->applicationEventListener;
this->eventManager.registerListener(applicationEventListener); this->eventManager.registerListener(applicationEventListener);
applicationEventListener->registerCallbackForEventType<Events::ShutdownApplication>( applicationEventListener->registerCallbackForEventType<Events::ShutdownApplication>(
std::bind(&Application::onShutdownApplicationRequest, this, std::placeholders::_1) std::bind(&Application::onShutdownApplicationRequest, this, std::placeholders::_1)
@@ -151,10 +151,11 @@ namespace Bloom
throw Exception("Failed to open settings file."); throw Exception("Failed to open settings file.");
} }
const auto jsonObject = QJsonDocument::fromJson(jsonSettingsFile.readAll()).object(); this->projectSettings = ProjectSettings(
QJsonDocument::fromJson(jsonSettingsFile.readAll()).object()
);
jsonSettingsFile.close(); jsonSettingsFile.close();
this->projectSettings = ProjectSettings(jsonObject);
return; return;
} catch (const std::exception& exception) { } catch (const std::exception& exception) {
@@ -430,6 +431,11 @@ namespace Bloom
} }
} }
void Application::onShutdownApplicationRequest(const Events::ShutdownApplication&) {
Logger::debug("ShutdownApplication event received.");
this->shutdown();
}
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 - it must have encountered a fatal error. // TargetController has unexpectedly shutdown - it must have encountered a fatal error.
@@ -437,11 +443,6 @@ namespace Bloom
} }
} }
void Application::onShutdownApplicationRequest(const Events::ShutdownApplication&) {
Logger::debug("ShutdownApplication event received.");
this->shutdown();
}
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.

View File

@@ -282,6 +282,11 @@ namespace Bloom
*/ */
void stopDebugServer(); void stopDebugServer();
/**
* Triggers a shutdown of Bloom and all of its components.
*/
void onShutdownApplicationRequest(const Events::ShutdownApplication&);
/** /**
* If the TargetController unexpectedly shuts down, the rest of the application will follow. * If the TargetController unexpectedly shuts down, the rest of the application will follow.
* *
@@ -296,10 +301,5 @@ namespace Bloom
* @param event * @param event
*/ */
void onDebugServerThreadStateChanged(const Events::DebugServerThreadStateChanged& event); void onDebugServerThreadStateChanged(const Events::DebugServerThreadStateChanged& event);
/**
* Triggers a shutdown of Bloom and all of its components.
*/
void onShutdownApplicationRequest(const Events::ShutdownApplication&);
}; };
} }

View File

@@ -33,11 +33,11 @@ namespace Bloom::DebugServers
const ProjectConfig& projectConfig, const ProjectConfig& projectConfig,
const EnvironmentConfig& environmentConfig, const EnvironmentConfig& environmentConfig,
const DebugServerConfig& debugServerConfig const DebugServerConfig& debugServerConfig
): )
eventManager(eventManager), : eventManager(eventManager)
projectConfig(projectConfig), , projectConfig(projectConfig)
environmentConfig(environmentConfig), , environmentConfig(environmentConfig)
debugServerConfig(debugServerConfig) {}; , debugServerConfig(debugServerConfig) {};
/** /**
* Entry point for the DebugServer. This must called from a dedicated thread. * Entry point for the DebugServer. This must called from a dedicated thread.