From cbb9231ece0b9bd09a32bd8c24c55b878fd7f181 Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Thu, 1 Aug 2024 21:35:27 -0400 Subject: [PATCH] fix some constructor operation order issues --- .../data/application_state.cpp | 18 ++++++++++++------ .../data/application_state.h | 12 ++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Source/lumatone_editor_library/data/application_state.cpp b/Source/lumatone_editor_library/data/application_state.cpp index 5ace219..033d30c 100644 --- a/Source/lumatone_editor_library/data/application_state.cpp +++ b/Source/lumatone_editor_library/data/application_state.cpp @@ -31,16 +31,17 @@ LumatoneApplicationState::LumatoneApplicationState(juce::ValueTree stateIn, Luma firmwareListeners = std::make_shared>(); midiListeners = std::make_shared>(); - layoutContext = std::make_shared(*mappingData); - controller = std::make_shared(*this, driverIn); - activityMonitor = std::make_shared(*this, &driverIn); - colourModel = std::make_shared(); - selectedKeys = std::make_shared>(); receiveSettingsStatus = std::make_shared(); receiveLayoutStatus = std::make_shared(); + layoutContext = std::make_shared(*mappingData); + colourModel = std::make_shared(); + + controller = std::make_shared(*this, driverIn); + activityMonitor = std::make_shared(*this, &driverIn); + loadStateProperties(stateIn); } @@ -276,6 +277,8 @@ void LumatoneApplicationState::setLayout(const LumatoneLayout &layoutIn) controller->sendCompleteMapping(layoutIn); } + clearContext(); + editorListeners->call(&LumatoneEditor::EditorListener::layoutChanged, *mappingData); } @@ -628,7 +631,7 @@ bool LumatoneApplicationState::Controller::requestCompleteDeviceConfig() if (appState.connectionState != ConnectionState::ONLINE) return false; - requestDeviceGlobalSettings(); + // requestDeviceGlobalSettings(); requestDeviceMapping(); return true; @@ -689,8 +692,11 @@ void LumatoneApplicationState::Controller::setActiveMacroButtonColour(juce::Colo void LumatoneApplicationState::DeviceController::setConnectionState(ConnectionState newState, bool sendNotification) { + bool stateChanged = deviceAppState.connectionState != newState; + deviceAppState.connectionState = newState; deviceAppState.setStateProperty(LumatoneApplicationProperty::ConnectionStateId, juce::var((int)deviceAppState.connectionState)); + if (sendNotification) getStatusListeners()->call(&LumatoneEditor::StatusListener::connectionStateChanged, deviceAppState.connectionState); } diff --git a/Source/lumatone_editor_library/data/application_state.h b/Source/lumatone_editor_library/data/application_state.h index ed5f55e..4713cef 100644 --- a/Source/lumatone_editor_library/data/application_state.h +++ b/Source/lumatone_editor_library/data/application_state.h @@ -159,13 +159,16 @@ class LumatoneApplicationState : public LumatoneState private: LumatoneFirmwareDriver& firmwareDriver; + std::shared_ptr receiveSettingsStatus; + std::shared_ptr receiveLayoutStatus; + std::shared_ptr layoutContext; - std::shared_ptr controller; - std::shared_ptr activityMonitor; std::shared_ptr colourModel; + + // Anything inheriting from this state should come after shared data + std::shared_ptr controller; + std::shared_ptr activityMonitor; - std::shared_ptr receiveSettingsStatus; - std::shared_ptr receiveLayoutStatus; bool contextIsSet = false; @@ -236,6 +239,7 @@ class LumatoneApplicationState : public LumatoneState private: friend class Controller; friend class DeviceController; + friend class LumatoneController; }; #endif // LUMATONE_APPLICATION_STATE_H