From 54044697b9485bbb9dc7a981fb8f8028f73ed6bc Mon Sep 17 00:00:00 2001 From: Sean Rhea Date: Mon, 14 Sep 2009 11:43:39 -0400 Subject: [PATCH] change smoothXYZ arrays into QVectors To match coding conventions and simplify memory management. --- src/AllPlot.cpp | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index dcc8451aa..7f5827757 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -299,13 +299,13 @@ AllPlot::recalc() QList list; - double *smoothWatts = new double[rideTimeSecs + 1]; - double *smoothHr = new double[rideTimeSecs + 1]; - double *smoothSpeed = new double[rideTimeSecs + 1]; - double *smoothCad = new double[rideTimeSecs + 1]; - double *smoothTime = new double[rideTimeSecs + 1]; - double *smoothDistance = new double[rideTimeSecs + 1]; - double *smoothAltitude = new double[rideTimeSecs + 1]; + QVector smoothWatts(rideTimeSecs + 1); + QVector smoothHr(rideTimeSecs + 1); + QVector smoothSpeed(rideTimeSecs + 1); + QVector smoothCad(rideTimeSecs + 1); + QVector smoothTime(rideTimeSecs + 1); + QVector smoothDistance(rideTimeSecs + 1); + QVector smoothAltitude(rideTimeSecs + 1); QMap interList; //Store the times and intervals // Times are unique, intervals are not always @@ -386,19 +386,19 @@ AllPlot::recalc() smoothTime[secs] = secs / 60.0; } - double *xaxis = bydist ? smoothDistance : smoothTime; + QVector &xaxis = bydist ? smoothDistance : smoothTime; // set curves if (wattsArray) - wattsCurve->setData(xaxis, smoothWatts, rideTimeSecs + 1); + wattsCurve->setData(xaxis.data(), smoothWatts.data(), rideTimeSecs + 1); if (hrArray) - hrCurve->setData(xaxis, smoothHr, rideTimeSecs + 1); + hrCurve->setData(xaxis.data(), smoothHr.data(), rideTimeSecs + 1); if (speedArray) - speedCurve->setData(xaxis, smoothSpeed, rideTimeSecs + 1); + speedCurve->setData(xaxis.data(), smoothSpeed.data(), rideTimeSecs + 1); if (cadArray) - cadCurve->setData(xaxis, smoothCad, rideTimeSecs + 1); + cadCurve->setData(xaxis.data(), smoothCad.data(), rideTimeSecs + 1); if (altArray) - altCurve->setData(xaxis, smoothAltitude, rideTimeSecs + 1); + altCurve->setData(xaxis.data(), smoothAltitude.data(), rideTimeSecs + 1); setAxisScale(xBottom, 0.0, bydist ? totalDist : smoothTime[rideTimeSecs]); setYMax(); @@ -429,21 +429,6 @@ AllPlot::recalc() } replot(); - - if(smoothWatts != NULL) - delete [] smoothWatts; - if(smoothHr != NULL) - delete [] smoothHr; - if(smoothSpeed != NULL) - delete [] smoothSpeed; - if(smoothCad != NULL) - delete [] smoothCad; - if(smoothTime != NULL) - delete [] smoothTime; - if(smoothDistance != NULL) - delete [] smoothDistance; - if(smoothAltitude != NULL) - delete [] smoothAltitude; } void