Fix merging params for discovered devices with user overrides

pull/135/head
Michael Zanetti 2019-02-25 12:46:45 +01:00
parent 7edec8198e
commit 8991e01526
1 changed files with 6 additions and 6 deletions

View File

@ -478,13 +478,13 @@ DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassI
return DeviceErrorDeviceDescriptorNotFound;
}
// Merge params. Use the ones from the descriptor unless overrides are provided in the function call
// Merge params from discovered descriptor and additional overrides provided on API call. User provided params have higher priority than discovery params.
ParamList finalParams;
foreach (const Param &param, descriptor.params()) {
if (params.hasParam(param.paramTypeId())) {
finalParams.append(Param(param.paramTypeId(), params.paramValue(param.paramTypeId())));
} else {
finalParams.append(param);
foreach (const ParamType &paramType, deviceClass.paramTypes()) {
if (params.hasParam(paramType.id())) {
finalParams.append(Param(paramType.id(), params.paramValue(paramType.id())));
} else if (descriptor.params().hasParam(paramType.id())) {
finalParams.append(Param(paramType.id(), descriptor.params().paramValue(paramType.id())));
}
}