hardware-monitor r268 - in trunk: . src
- From: olau svn gnome org
- To: svn-commits-list gnome org
- Subject: hardware-monitor r268 - in trunk: . src
- Date: Sun, 9 Nov 2008 20:17:34 +0000 (UTC)
Author: olau
Date: Sun Nov 9 20:17:33 2008
New Revision: 268
URL: http://svn.gnome.org/viewvc/hardware-monitor?rev=268&view=rev
Log:
2008-11-09 Ole Laursen <olau hardworking dk>
* src/column-view.cpp, src/curve-view.cpp, src/flame-view.cpp,
src/bar-view.cpp, src/monitor.hpp: Try to prevent stray values
returned by the monitored devices from causing the charts to go
berserk by clamping them (inspired by an excellent trace by Karl
Chen).
Modified:
trunk/ChangeLog
trunk/src/bar-view.cpp
trunk/src/column-view.cpp
trunk/src/curve-view.cpp
trunk/src/flame-view.cpp
trunk/src/monitor.hpp
Modified: trunk/src/bar-view.cpp
==============================================================================
--- trunk/src/bar-view.cpp (original)
+++ trunk/src/bar-view.cpp Sun Nov 9 20:17:33 2008
@@ -148,6 +148,8 @@
max = 0.0000001;
double box_frac = total_no_boxes * value / max;
+ if (box_frac > total_no_boxes)
+ box_frac = total_no_boxes;
unsigned int no_boxes = int(std::ceil(box_frac));
double alpha = box_frac - std::floor(box_frac);
Modified: trunk/src/column-view.cpp
==============================================================================
--- trunk/src/column-view.cpp (original)
+++ trunk/src/column-view.cpp Sun Nov 9 20:17:33 2008
@@ -117,7 +117,9 @@
pixbuf->fill(color & 0xFFFFFF00);
- double max = std::max(monitor->max(), 0.000001); // avoid division by zero
+ double max = monitor->max();
+ if (max <= 0)
+ max = 0.0000001;
// start from right
double l = width - ColumnView::pixels_per_sample
Modified: trunk/src/curve-view.cpp
==============================================================================
--- trunk/src/curve-view.cpp (original)
+++ trunk/src/curve-view.cpp Sun Nov 9 20:17:33 2008
@@ -111,7 +111,9 @@
line->property_width_units() = line_width;
- double max = std::max(monitor->max(), 0.000001); // avoid division by zero
+ double max = monitor->max();
+ if (max <= 0)
+ max = 0.0000001;
Gnome::Canvas::Points points;
points.reserve(value_history.values.size());
@@ -121,6 +123,8 @@
do {
double y = line_width/2 + (1 - (*vi / max)) * (height - line_width/2);
+ if (y < 0)
+ y = 0;
points.push_back(Gnome::Art::Point(x, y));
x -= CurveView::pixels_per_sample;
Modified: trunk/src/flame-view.cpp
==============================================================================
--- trunk/src/flame-view.cpp (original)
+++ trunk/src/flame-view.cpp Sun Nov 9 20:17:33 2008
@@ -150,6 +150,9 @@
void Flame::recompute_fuel()
{
int ratio = int(value / max * 255);
+
+ if (ratio > 255)
+ ratio = 255;
if (next_refuel <= 0) {
next_refuel = random_between(5, 20);
Modified: trunk/src/monitor.hpp
==============================================================================
--- trunk/src/monitor.hpp (original)
+++ trunk/src/monitor.hpp Sun Nov 9 20:17:33 2008
@@ -43,6 +43,8 @@
void measure()
{
measured_value = do_measure();
+ if (measured_value < 0) // safety check
+ measured_value = 0;
}
// fetch the currently measured value
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]