Fix issues with empty json and unknown path

This commit is contained in:
Adam Honse committed 2020-11-10 15:49:56 -06:00
1 parent 8131b94a5d
commit c8e547343b
2 files changed
+22 -6

No files matched your search

+10 -6
View File
@@ -46,11 +46,6 @@ ResourceManager::ResourceManager()
\*-------------------------------------------------------------------------*/
server = new NetworkServer(rgb_controllers_hw);
/*-------------------------------------------------------------------------*\
| Create OpenRGB configuration directory if it doesn't exist |
\*-------------------------------------------------------------------------*/
std::experimental::filesystem::create_directories(GetConfigurationDirectory());
/*-------------------------------------------------------------------------*\
| Load sizes list from file |
\*-------------------------------------------------------------------------*/
@@ -220,6 +215,15 @@ std::string ResourceManager::GetConfigurationDirectory()
if(config_dir != "")
{
config_dir = config_dir + "/OpenRGB/";
/*-------------------------------------------------------------------------*\
| Create OpenRGB configuration directory if it doesn't exist |
\*-------------------------------------------------------------------------*/
std::experimental::filesystem::create_directories(config_dir);
}
else
{
config_dir = "./";
}
return(config_dir);
@@ -355,7 +359,7 @@ void ResourceManager::DetectDevicesThreadFunction()
| Open device disable list and read in disabled |
| device strings |
\*-------------------------------------------------*/
disabled_devices_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Setting_DisabledDevices");
disabled_devices_settings = settings_manager->GetSettings("Setting_DisabledDevices");
if(disabled_devices_settings.contains("disabled"))
{
+12
View File
@@ -26,10 +26,22 @@ SettingsManager::~SettingsManager()
json SettingsManager::GetSettings(std::string settings_key)
{
/*---------------------------------------------------------*\
| Check to see if the key exists in the settings store and |
| return the settings associated with the key if it exists |
\*---------------------------------------------------------*/
if(settings_data.contains(settings_key))
{
return(settings_data[settings_key]);
}
/*---------------------------------------------------------*\
| If the settings store doesn't contain the key, create an |
| empty json and return it |
\*---------------------------------------------------------*/
json empty;
return(empty);
}
void SettingsManager::LoadSettings(std::string filename)