Use up-to-date controller list in profile manager

This commit is contained in:
Adam Honse 2020-12-02 21:53:14 -06:00
parent 7a305b1440
commit 3f7c981ba2
3 changed files with 13 additions and 6 deletions

View file

@ -9,7 +9,7 @@
namespace fs = std::experimental::filesystem; namespace fs = std::experimental::filesystem;
ProfileManager::ProfileManager(std::vector<RGBController *>& control, std::string config_dir) : controllers(control) ProfileManager::ProfileManager(std::string config_dir)
{ {
configuration_directory = config_dir; configuration_directory = config_dir;
UpdateProfileList(); UpdateProfileList();
@ -22,6 +22,11 @@ ProfileManager::~ProfileManager()
bool ProfileManager::SaveProfile(std::string profile_name) bool ProfileManager::SaveProfile(std::string profile_name)
{ {
/*---------------------------------------------------------*\
| Get the list of controllers from the resource manager |
\*---------------------------------------------------------*/
std::vector<RGBController *> controllers = ResourceManager::get()->GetRGBControllers();
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| If a name was entered, save the profile file | | If a name was entered, save the profile file |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
@ -269,6 +274,11 @@ bool ProfileManager::LoadProfileWithOptions
std::string filename = configuration_directory + profile_name; std::string filename = configuration_directory + profile_name;
/*---------------------------------------------------------*\
| Get the list of controllers from the resource manager |
\*---------------------------------------------------------*/
std::vector<RGBController *> controllers = ResourceManager::get()->GetRGBControllers();
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Open input file in binary mode | | Open input file in binary mode |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/

View file

@ -5,7 +5,7 @@
class ProfileManager class ProfileManager
{ {
public: public:
ProfileManager(std::vector<RGBController *>& control, std::string config_dir); ProfileManager(std::string config_dir);
~ProfileManager(); ~ProfileManager();
bool SaveProfile(std::string profile_name); bool SaveProfile(std::string profile_name);
@ -31,9 +31,6 @@ public:
void SetConfigurationDirectory(std::string directory); void SetConfigurationDirectory(std::string directory);
protected:
std::vector<RGBController *>& controllers;
private: private:
std::string configuration_directory; std::string configuration_directory;

View file

@ -50,7 +50,7 @@ ResourceManager::ResourceManager()
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Load sizes list from file | | Load sizes list from file |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
profile_manager = new ProfileManager(rgb_controllers, GetConfigurationDirectory()); profile_manager = new ProfileManager(GetConfigurationDirectory());
rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes.ors"); rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes.ors");
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\