Fixed the issue that SpeedFanPlugin crashes if SpeedFanType is not TEMPERATURE.

This commit is contained in:
spx 2010-06-02 14:47:41 +00:00
parent 0de1483e75
commit 7a919f35fc

View File

@ -60,6 +60,7 @@ enum SensorType
enum TempScale enum TempScale
{ {
SCALE_SOURCE,
SCALE_CENTIGRADE, SCALE_CENTIGRADE,
SCALE_FARENHEIT, SCALE_FARENHEIT,
SCALE_KELVIN SCALE_KELVIN
@ -153,14 +154,25 @@ double Update2(UINT id)
std::map<UINT, TempScale>::const_iterator scale = g_Scales.find(id); std::map<UINT, TempScale>::const_iterator scale = g_Scales.find(id);
std::map<UINT, UINT>::const_iterator number = g_Numbers.find(id); std::map<UINT, UINT>::const_iterator number = g_Numbers.find(id);
if(type == g_Types.end() || number == g_Numbers.end() || ((*type).second == TYPE_TEMP && scale == g_Scales.end())) if(type == g_Types.end() || number == g_Numbers.end())
{ {
return 0.0; // No id in the map. How this can be ???? return 0.0; // No id in the map. How this can be ????
} }
if (ReadSharedData((*type).second, (*scale).second, (*number).second, &value)) if ((*type).second == TYPE_TEMP)
{ {
return value; if (scale != g_Scales.end() &&
ReadSharedData((*type).second, (*scale).second, (*number).second, &value))
{
return value;
}
}
else
{
if (ReadSharedData((*type).second, SCALE_SOURCE, (*number).second, &value))
{
return value;
}
} }
return 0.0; return 0.0;