From 7a919f35fccfc7626283d198e724ef9a2bc7a670 Mon Sep 17 00:00:00 2001 From: spx Date: Wed, 2 Jun 2010 14:47:41 +0000 Subject: [PATCH] Fixed the issue that SpeedFanPlugin crashes if SpeedFanType is not TEMPERATURE. --- Plugins/PluginSpeedFan/SpeedFanPlugin.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp b/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp index 5aeb04d7..8b939bf0 100644 --- a/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp +++ b/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp @@ -60,6 +60,7 @@ enum SensorType enum TempScale { + SCALE_SOURCE, SCALE_CENTIGRADE, SCALE_FARENHEIT, SCALE_KELVIN @@ -153,14 +154,25 @@ double Update2(UINT id) std::map::const_iterator scale = g_Scales.find(id); std::map::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 ???? } - - 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;