summaryrefslogblamecommitdiffstats
path: root/kde/patch/libksysguard/libksysguard_isnan.patch
blob: c6ce1e9f29fd5d8319d2ed3d96d8227baff1214f (plain) (tree)















































































































































































                                                                                                                                                
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);
 }