ActivityMonitor: fix Temperature presentation if no sensor is available.
On machines with no acpi_thermal sensor, enabling the thermal readings
was showing the value as "-2.077.252.342 °C".
Let's show "No thermal sensor" / "0 °C" instead.
Change-Id: I4ba74e648b8826635cb4f4145540c833d1058220
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9764
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Diff
src/apps/activitymonitor/DataSource.cpp | 7 +++++++
src/apps/activitymonitor/SystemInfoHandler.cpp | 7 +++++++
2 files changed, 12 insertions(+), 2 deletions(-)
@@ -1013,7 +1013,12 @@
ThermalDataSource::NextValue(SystemInfo& info)
{
fLabel = info.ThermalZone();
int64 value = (int64)ceilf(info.Temperature() * 1000000);
float temperature = info.Temperature();
if (isnan(temperature))
return 0;
int64 value = (int64)ceilf(temperature * 1000000);
if (value > fMaximum)
SetLimits(0, value);
@@ -11,6 +11,7 @@
#include <string.h>
#include <unistd.h>
#include <Catalog.h>
#include <Clipboard.h>
#include <Drivers.h>
#include <Handler.h>
@@ -20,7 +21,10 @@
#include <Messenger.h>
#include <Roster.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "SystemInfoHandler"
SystemInfoHandler::SystemInfoHandler()
: BHandler("SystemInfoHandler")
{
@@ -35,6 +39,8 @@
char buffer[256];
if ((fThermalFD > 0) && (ioctl(fThermalFD, B_GET_DEVICE_NAME, buffer, sizeof(buffer)) == B_OK))
fThermalZoneName = buffer;
else
fThermalZoneName = B_TRANSLATE("No thermal sensor");
}
@@ -98,7 +104,6 @@
}
}