summaryrefslogtreecommitdiffstats
path: root/kde/patch/libksysguard/libksysguard_isnan.patch
blob: c6ce1e9f29fd5d8319d2ed3d96d8227baff1214f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
From: David Rosca <nowrep@gmail.com>
Date: Tue, 23 Feb 2016 16:32:35 +0000
Subject: signalplotter: Use std namespaced isnan and isinf
X-Git-Tag: v5.5.95
X-Git-Url: http://quickgit.kde.org/?p=libksysguard.git&a=commitdiff&h=b0578798eb3f5bdad0a25ea9b4a52c53ebcfc020
---
signalplotter: Use std namespaced isnan and isinf

Test Plan: Fixes build for me.

Reviewers: #plasma, ivan

Reviewed By: ivan

Subscribers: ivan, plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1010
---


--- a/signalplotter/ksignalplotter.cpp
+++ b/signalplotter/ksignalplotter.cpp
@@ -32,8 +32,6 @@
 #include "ksignalplotter_p.h"
 #include "processcore/processcore_debug.h"
 
-#include <math.h>  //For floor, ceil, log10 etc for calculating ranges
-
 #include <QPainter>
 #include <QPixmap>
 #include <QPainterPath>
@@ -49,7 +47,7 @@
 
 #include <klocalizedstring.h>
 #include <kiconloader.h>
-#include <math.h>
+#include <cmath>
 #include <limits>
 
 #ifdef SVG_SUPPORT
@@ -485,20 +483,20 @@
         qreal value=0;
         for(int i = sampleBuf.count()-1; i>= 0; i--) {
             qreal newValue = sampleBuf[i];
-            if( !isinf(newValue) && !isnan(newValue) )
+            if( !std::isinf(newValue) && !std::isnan(newValue) )
                 value += newValue;
         }
-        if(isnan(mMinValue) || mMinValue > value) mMinValue = value;
-        if(isnan(mMaxValue) || mMaxValue < value) mMaxValue = value;
+        if(std::isnan(mMinValue) || mMinValue > value) mMinValue = value;
+        if(std::isnan(mMaxValue) || mMaxValue < value) mMaxValue = value;
         if(value > 0.7*mMaxValue)
             mRescaleTime = time;
     } else {
         qreal value;
         for(int i = sampleBuf.count()-1; i>= 0; i--) {
             value = sampleBuf[i];
-            if( !isinf(value) && !isnan(value) ) {
-                if(isnan(mMinValue) || mMinValue > value) mMinValue = value;
-                if(isnan(mMaxValue) || mMaxValue < value) mMaxValue = value;
+            if( !std::isinf(value) && !std::isnan(value) ) {
+                if(std::isnan(mMinValue) || mMinValue > value) mMinValue = value;
+                if(std::isnan(mMaxValue) || mMaxValue < value) mMaxValue = value;
                 if(value > 0.7*mMaxValue)
                     mRescaleTime = time;
             }
@@ -789,9 +787,9 @@
     qreal max = mUserMaxValue;
     qreal min = mUserMinValue;
     if( mUseAutoRange ) {
-        if(!isnan(mMaxValue) && mMaxValue * 0.99 > max)  //Allow max value to go very slightly over the given max, for rounding reasons
+        if(!std::isnan(mMaxValue) && mMaxValue * 0.99 > max)  //Allow max value to go very slightly over the given max, for rounding reasons
             max = mMaxValue;
-        if(!isnan(mMinValue) && mMinValue * 0.99 < min) {
+        if(!std::isnan(mMinValue) && mMinValue * 0.99 < min) {
             min = mMinValue;
         }
     }
@@ -920,23 +918,23 @@
     bool firstLine = true;
     for (int j = 0; j < count; ++j) {
         qreal point0 = datapoints[j];
-        if( isnan(point0) )
+        if( std::isnan(point0) )
             continue; //Just do not draw points with nans. skip them
 
         qreal point1 = prev_datapoints[j];
         qreal point2 = prev_prev_datapoints[j];
 
-        if(isnan(point1))
+        if(std::isnan(point1))
             point1 = point0;
-        else if(mSmoothGraph && !isinf(point1)) {
+        else if(mSmoothGraph && !std::isinf(point1)) {
             // Apply a weighted average just to smooth the graph out a bit
             // Do not try to smooth infinities or nans
             point0 = (2*point0 + point1)/3;
-            if(!isnan(point2) && !isinf(point2))
+            if(!std::isnan(point2) && !std::isinf(point2))
                 point1 = (2*point1 + point2)/3;
             // We don't bother to average out y2.  This will introduce slight inaccuracies in the gradients, but they aren't really noticeable.
         }
-        if(isnan(point2))
+        if(std::isnan(point2))
             point2 = point1;
 
         if (mStackBeams) {
@@ -1046,12 +1044,12 @@
 }
 QString KSignalPlotter::lastValueAsString( int i, int precision) const
 {
-    if(d->mBeamData.isEmpty() || d->mBeamData.first().size() <= i || isnan(d->mBeamData.first().at(i))) return QString();
+    if(d->mBeamData.isEmpty() || d->mBeamData.first().size() <= i || std::isnan(d->mBeamData.first().at(i))) return QString();
     return valueAsString(d->mBeamData.first().at(i), precision); //retrieve the newest value for this beam
 }
 QString KSignalPlotter::valueAsString( qreal value, int precision) const
 {
-    if(isnan(value))
+    if(std::isnan(value))
         return QString();
     value = value / d->mScaleDownBy; // scale the value.  E.g. from Bytes to KiB
     return d->scaledValueAsString(value, precision);

--- a/tests/signalplottertest.cpp
+++ b/tests/signalplottertest.cpp
@@ -56,8 +56,8 @@
     s->addBeam(Qt::blue);
     s->addBeam(Qt::red);
 
-    QVERIFY( isnan(s->lastValue(0)) ); //unset, so should default to NaN
-    QVERIFY( isnan(s->lastValue(1)) ); //unset, so should default to NaN
+    QVERIFY( std::isnan(s->lastValue(0)) ); //unset, so should default to NaN
+    QVERIFY( std::isnan(s->lastValue(1)) ); //unset, so should default to NaN
     QCOMPARE(s->numBeams(), 2);
     QVERIFY(s->beamColor(0) == Qt::blue);
     QVERIFY(s->beamColor(1) == Qt::red);
@@ -92,7 +92,7 @@
     QVERIFY(s->beamColor(0) == Qt::blue);
     QVERIFY(s->beamColor(1) == Qt::red);
     QCOMPARE(s->lastValue(0), 1.0);
-    QVERIFY( isnan(s->lastValue(1)) ); //unset, so should default to NaN
+    QVERIFY( std::isnan(s->lastValue(1)) ); //unset, so should default to NaN
 }
 
 void TestSignalPlotter::testReorderBeams()
@@ -153,8 +153,8 @@
     s->addBeam(Qt::blue);
     s->addBeam(Qt::red);
     QCOMPARE(s->numBeams(), 2);
-    QVERIFY(isnan(s->lastValue(0))); //unset, so should default to NaN
-    QVERIFY(isnan(s->lastValue(1))); //unset, so should default to NaN
+    QVERIFY(std::isnan(s->lastValue(0))); //unset, so should default to NaN
+    QVERIFY(std::isnan(s->lastValue(1))); //unset, so should default to NaN
     //Add some data
     QList<qreal> data;
     data << 1.0 << 2.0;
@@ -189,13 +189,13 @@
     QCOMPARE(s->numBeams(), 3);
     QCOMPARE(s->lastValue(0), 2.0);
     QCOMPARE(s->lastValue(1), 1.0);
-    QVERIFY(isnan(s->lastValue(2))); //unset, so should default to NaN
+    QVERIFY(std::isnan(s->lastValue(2))); //unset, so should default to NaN
 
     newOrder.clear();
     newOrder << 2 << 0 << 1;
     s->reorderBeams(newOrder);
     QCOMPARE(s->numBeams(), 3);
-    QVERIFY(isnan(s->lastValue(0))); //unset, so should default to NaN
+    QVERIFY(std::isnan(s->lastValue(0))); //unset, so should default to NaN
     QCOMPARE(s->lastValue(1), 2.0);
     QCOMPARE(s->lastValue(2), 1.0);
 }