From 8d0dc68da053ad1f080cb5f66a8b743e0f9192d7 Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 9 Feb 2022 17:49:25 +0000 Subject: [PATCH] Tidying --- src/Application.cpp | 17 +++++++++-------- src/Application.hpp | 10 +++++----- src/DebugServers/DebugServer.hpp | 10 +++++----- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 3435aa9e..d38e46ad 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -87,7 +87,7 @@ namespace Bloom } void Application::startup() { - auto applicationEventListener = this->applicationEventListener; + auto& applicationEventListener = this->applicationEventListener; this->eventManager.registerListener(applicationEventListener); applicationEventListener->registerCallbackForEventType( std::bind(&Application::onShutdownApplicationRequest, this, std::placeholders::_1) @@ -151,10 +151,11 @@ namespace Bloom 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(); - this->projectSettings = ProjectSettings(jsonObject); return; } 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) { if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) { // 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) { if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) { // DebugServer has unexpectedly shutdown - it must have encountered a fatal error. diff --git a/src/Application.hpp b/src/Application.hpp index 26330f0e..75223da1 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -282,6 +282,11 @@ namespace Bloom */ 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. * @@ -296,10 +301,5 @@ namespace Bloom * @param event */ void onDebugServerThreadStateChanged(const Events::DebugServerThreadStateChanged& event); - - /** - * Triggers a shutdown of Bloom and all of its components. - */ - void onShutdownApplicationRequest(const Events::ShutdownApplication&); }; } diff --git a/src/DebugServers/DebugServer.hpp b/src/DebugServers/DebugServer.hpp index 8cd45665..cd42eae3 100644 --- a/src/DebugServers/DebugServer.hpp +++ b/src/DebugServers/DebugServer.hpp @@ -33,11 +33,11 @@ namespace Bloom::DebugServers const ProjectConfig& projectConfig, const EnvironmentConfig& environmentConfig, const DebugServerConfig& debugServerConfig - ): - eventManager(eventManager), - projectConfig(projectConfig), - environmentConfig(environmentConfig), - debugServerConfig(debugServerConfig) {}; + ) + : eventManager(eventManager) + , projectConfig(projectConfig) + , environmentConfig(environmentConfig) + , debugServerConfig(debugServerConfig) {}; /** * Entry point for the DebugServer. This must called from a dedicated thread.