From 82934425ab6a58ee486fdc8d68c640bb4df272e1 Mon Sep 17 00:00:00 2001 From: Sean Rhea Date: Mon, 9 Nov 2009 09:16:09 -0500 Subject: [PATCH] fix bug in 2f8d101, need to strip path The filename argument actually contained the whole path. This fix passes the filename and directory separately, so that the anchored regex works. --- src/CpintPlot.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/CpintPlot.cpp b/src/CpintPlot.cpp index 6fdb3c858..e2b7d460f 100644 --- a/src/CpintPlot.cpp +++ b/src/CpintPlot.cpp @@ -205,9 +205,10 @@ cpi_filename_to_date(const QString filename) { } static int -read_one(const QString &inname, QVector &bests, QVector *bestDates, - QHash *cpiDataInBests) +read_one(const QDir& dir, const QString &filename, QVector &bests, + QVector *bestDates, QHash *cpiDataInBests) { + QString inname = dir.absoluteFilePath(filename); FILE *in = fopen(inname.toAscii().constData(), "r"); if (!in) return -1; @@ -235,7 +236,7 @@ read_one(const QString &inname, QVector &bests, QVector *bestDate if (bests[secs] < watts){ bests[secs] = watts; if (bestDates) - (*bestDates)[secs] = cpi_filename_to_date(inname); + (*bestDates)[secs] = cpi_filename_to_date(filename); // mark the filename as having contributed to the bests // Note this contribution may subsequently be over-written, so @@ -576,7 +577,7 @@ CpintPlot::calculate(RideItem *rideItem) progress.show(); foreach (const QString &filename, list) { QString path = dir.absoluteFilePath(filename); - read_one(path, bests, &bestDates, &cpiDataInBests); + read_one(dir, filename, bests, &bestDates, &cpiDataInBests); progress.setValue(progress.value() + 1); QCoreApplication::processEvents(); if (progress.wasCanceled()) { @@ -630,8 +631,8 @@ CpintPlot::calculate(RideItem *rideItem) thisCurve = NULL; } QVector bests; - QString inname = dir.absoluteFilePath(file.completeBaseName() + ".cpi"); - if ((read_one(inname, bests, NULL, NULL) == 0) && bests.size()) { + QString filename = file.completeBaseName() + ".cpi"; + if ((read_one(dir, filename, bests, NULL, NULL) == 0) && bests.size()) { QVector timeArray(bests.size()); int maxNonZero = 0; for (int i = 0; i < bests.size(); ++i) {