This commit is contained in:
parent
d8b7913d9b
commit
2120208e84
@ -1,168 +0,0 @@
|
|||||||
From b0578798eb3f5bdad0a25ea9b4a52c53ebcfc020 Mon Sep 17 00:00:00 2001
|
|
||||||
From: David Rosca <nowrep@gmail.com>
|
|
||||||
Date: Tue, 23 Feb 2016 17:32:35 +0100
|
|
||||||
Subject: [PATCH] signalplotter: Use std namespaced isnan and isinf
|
|
||||||
|
|
||||||
Differential Revision: https://phabricator.kde.org/D1010
|
|
||||||
---
|
|
||||||
signalplotter/ksignalplotter.cpp | 34 ++++++++++++++++------------------
|
|
||||||
tests/signalplottertest.cpp | 14 +++++++-------
|
|
||||||
2 files changed, 23 insertions(+), 25 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/signalplotter/ksignalplotter.cpp b/signalplotter/ksignalplotter.cpp
|
|
||||||
index 6847f16..3737227 100644
|
|
||||||
--- 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 @@ void KSignalPlotterPrivate::recalculateMaxMinValueForSample(const QList<qreal>&s
|
|
||||||
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 @@ void KSignalPlotterPrivate::calculateNiceRange()
|
|
||||||
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 @@ void KSignalPlotterPrivate::drawBeam(QPainter *p, const QRect &boundingBox, int
|
|
||||||
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 @@ qreal KSignalPlotter::lastValue( int i) const
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
diff --git a/tests/signalplottertest.cpp b/tests/signalplottertest.cpp
|
|
||||||
index fa058d5..8b3b394 100644
|
|
||||||
--- a/tests/signalplottertest.cpp
|
|
||||||
+++ b/tests/signalplottertest.cpp
|
|
||||||
@@ -56,8 +56,8 @@ void TestSignalPlotter::testAddRemoveBeamsWithData()
|
|
||||||
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 @@ void TestSignalPlotter::testAddRemoveBeamsWithData()
|
|
||||||
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 @@ void TestSignalPlotter::testReorderBeamsWithData()
|
|
||||||
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 @@ void TestSignalPlotter::testReorderBeamsWithData()
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
@ -27,8 +27,6 @@ Url: http://www.kde.org
|
|||||||
Source: libksysguard-%{version}.tar.xz
|
Source: libksysguard-%{version}.tar.xz
|
||||||
Source1: baselibs.conf
|
Source1: baselibs.conf
|
||||||
Source99: %{name}-rpmlintrc
|
Source99: %{name}-rpmlintrc
|
||||||
# PATCH-FIX-UPSTREAM libksysguard5-glibc-2.23.patch dimstar@opensuse.org -- Fix build with glibc 2.23
|
|
||||||
Patch0: libksysguard5-glibc-2.23.patch
|
|
||||||
BuildRequires: extra-cmake-modules >= 1.2.0
|
BuildRequires: extra-cmake-modules >= 1.2.0
|
||||||
BuildRequires: kf5-filesystem
|
BuildRequires: kf5-filesystem
|
||||||
BuildRequires: xz
|
BuildRequires: xz
|
||||||
@ -89,7 +87,6 @@ for actions that require elevated privileges.
|
|||||||
%lang_package
|
%lang_package
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n libksysguard-%{version}
|
%setup -q -n libksysguard-%{version}
|
||||||
%patch0 -p1
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%cmake_kf5 -d build -- -DCMAKE_INSTALL_LOCALEDIR=share/locale/kf5
|
%cmake_kf5 -d build -- -DCMAKE_INSTALL_LOCALEDIR=share/locale/kf5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user