Skip to content

Commit

Permalink
fix some constructor operation order issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Aug 2, 2024
1 parent 9d0bf98 commit cbb9231
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
18 changes: 12 additions & 6 deletions Source/lumatone_editor_library/data/application_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ LumatoneApplicationState::LumatoneApplicationState(juce::ValueTree stateIn, Luma
firmwareListeners = std::make_shared<juce::ListenerList<LumatoneEditor::FirmwareListener>>();
midiListeners = std::make_shared<juce::ListenerList<LumatoneEditor::MidiListener>>();

layoutContext = std::make_shared<LumatoneContext>(*mappingData);
controller = std::make_shared<LumatoneController>(*this, driverIn);
activityMonitor = std::make_shared<DeviceActivityMonitor>(*this, &driverIn);
colourModel = std::make_shared<LumatoneColourModel>();

selectedKeys = std::make_shared<juce::Array<MappedLumatoneKey>>();

receiveSettingsStatus = std::make_shared<FirmwareSupport::ReceiveSettingsStatus>();
receiveLayoutStatus = std::make_shared<FirmwareSupport::ReceiveLayoutStatus>();

layoutContext = std::make_shared<LumatoneContext>(*mappingData);
colourModel = std::make_shared<LumatoneColourModel>();

controller = std::make_shared<LumatoneController>(*this, driverIn);
activityMonitor = std::make_shared<DeviceActivityMonitor>(*this, &driverIn);

loadStateProperties(stateIn);
}

Expand Down Expand Up @@ -276,6 +277,8 @@ void LumatoneApplicationState::setLayout(const LumatoneLayout &layoutIn)
controller->sendCompleteMapping(layoutIn);
}

clearContext();

editorListeners->call(&LumatoneEditor::EditorListener::layoutChanged, *mappingData);
}

Expand Down Expand Up @@ -628,7 +631,7 @@ bool LumatoneApplicationState::Controller::requestCompleteDeviceConfig()
if (appState.connectionState != ConnectionState::ONLINE)
return false;

requestDeviceGlobalSettings();
// requestDeviceGlobalSettings();
requestDeviceMapping();

return true;
Expand Down Expand Up @@ -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);
}
Expand Down
12 changes: 8 additions & 4 deletions Source/lumatone_editor_library/data/application_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,16 @@ class LumatoneApplicationState : public LumatoneState
private:
LumatoneFirmwareDriver& firmwareDriver;

std::shared_ptr<FirmwareSupport::ReceiveSettingsStatus> receiveSettingsStatus;
std::shared_ptr<FirmwareSupport::ReceiveLayoutStatus> receiveLayoutStatus;

std::shared_ptr<LumatoneContext> layoutContext;
std::shared_ptr<LumatoneController> controller;
std::shared_ptr<DeviceActivityMonitor> activityMonitor;
std::shared_ptr<LumatoneColourModel> colourModel;

// Anything inheriting from this state should come after shared data
std::shared_ptr<LumatoneController> controller;
std::shared_ptr<DeviceActivityMonitor> activityMonitor;

std::shared_ptr<FirmwareSupport::ReceiveSettingsStatus> receiveSettingsStatus;
std::shared_ptr<FirmwareSupport::ReceiveLayoutStatus> receiveLayoutStatus;

bool contextIsSet = false;

Expand Down Expand Up @@ -236,6 +239,7 @@ class LumatoneApplicationState : public LumatoneState
private:
friend class Controller;
friend class DeviceController;
friend class LumatoneController;
};

#endif // LUMATONE_APPLICATION_STATE_H

0 comments on commit cbb9231

Please sign in to comment.