mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Fix SEGV on unsupported device types
.. train tool segvs on device types that were previously configured but are no longer supported. This fix now silently ignores any devices that are no longer supported. Fixes #497.
This commit is contained in:
@@ -69,12 +69,27 @@ DeviceConfigurations::readConfig()
|
||||
count = configVal.toInt();
|
||||
}
|
||||
|
||||
// get list of supported devices
|
||||
DeviceTypes all;
|
||||
|
||||
// for each device
|
||||
for (int i=0; i< count; i++) {
|
||||
|
||||
DeviceConfiguration Entry;
|
||||
|
||||
QString configStr = QString("%1%2").arg(GC_DEV_NAME).arg(i+1);
|
||||
QString configStr = QString("%1%2").arg(GC_DEV_TYPE).arg(i+1);
|
||||
configVal = appsettings->value(NULL, configStr);
|
||||
Entry.type = configVal.toInt();
|
||||
|
||||
bool supported = false;
|
||||
foreach(DeviceType s, all.getList()) {
|
||||
if (s.type == Entry.type) supported = true;
|
||||
}
|
||||
|
||||
// skip unsupported devices
|
||||
if (supported == false) continue;
|
||||
|
||||
configStr = QString("%1%2").arg(GC_DEV_NAME).arg(i+1);
|
||||
configVal = appsettings->value(NULL, configStr);
|
||||
Entry.name = configVal.toString();
|
||||
|
||||
@@ -82,10 +97,6 @@ DeviceConfigurations::readConfig()
|
||||
configVal = appsettings->value(NULL, configStr);
|
||||
Entry.portSpec = configVal.toString();
|
||||
|
||||
configStr = QString("%1%2").arg(GC_DEV_TYPE).arg(i+1);
|
||||
configVal = appsettings->value(NULL, configStr);
|
||||
Entry.type = configVal.toInt();
|
||||
|
||||
configStr = QString("%1%2").arg(GC_DEV_WHEEL).arg(i+1);
|
||||
configVal = appsettings->value(NULL, configStr);
|
||||
Entry.wheelSize = configVal.toInt();
|
||||
|
||||
Reference in New Issue
Block a user