From c8523a2716884f2df56bb21cef644e573d421029 Mon Sep 17 00:00:00 2001 From: qheath Date: Wed, 30 May 2018 21:33:02 +0900 Subject: [PATCH] various minor bugfixes + warningfixes (#2878) * fix unclosed file descriptors * remove various compiler warnings sometimes it was only ambiguous indentation, sometimes bugs were fixed: - forgotten `break;` instructions or `fallthrough` annotations: - src/ANT/ANTChannel.cpp - src/Charts/CriticalPowerWindow.cpp - src/Charts/MUPlot.cpp - src/Core/DataFilter.cpp - src/FileIO/RideFileCache.cpp - src/FileIO/RideFileCommand.cpp - src/Train/DialWindow.cpp - forgotten braces: - lmfit/lmmin.c - src/FileIO/XDataDialog.cpp - test on the wrong variables: - src/Gui/Pages.cpp - wrong parenthesis - src/Charts/CPPlot.cpp - missing macro argument - src/Cloud/WithingsDownload.cpp - missing `return;` statement - src/Cloud/Xert.cpp - unused variables - src/Gui/DiarySidebar.cpp - unclear indentation - src/Core/RideItem.cpp - src/FileIO/BinRideFile.cpp - src/Metrics/PaceZones.cpp - src/Metrics/RideMetadata.cpp - src/Metrics/Zones.cpp * remove unnecessary Leaf::Parameters enum value from data filters lists of parameters don't exist as such outside of the parser, and have no business using the same type `Leaf` as complete terms anyway * remove unnecessary argument `leaf1.print(leaf2,...)` would print `leaf2` and completely ignore `leaf1`, so now `leaf2.print(...)` is used instead --- lmfit/lmmin.c | 17 +-- qwt/examples/cpuplot/cpustat.cpp | 1 + src/ANT/ANTChannel.cpp | 1 + src/Charts/CPPlot.cpp | 2 +- src/Charts/CriticalPowerWindow.cpp | 1 + src/Charts/MUPlot.cpp | 1 + src/Cloud/CloudService.cpp | 17 ++- src/Cloud/LocalFileStore.cpp | 2 - src/Cloud/WithingsDownload.cpp | 20 ++-- src/Cloud/Xert.cpp | 4 +- src/Core/BodyMeasures.cpp | 1 + src/Core/DataFilter.cpp | 186 ++++++++++++++--------------- src/Core/DataFilter.h | 4 +- src/Core/DataFilter.y | 17 +-- src/Core/HrvMeasures.cpp | 1 + src/Core/RideItem.cpp | 35 +++--- src/FileIO/BinRideFile.cpp | 2 +- src/FileIO/RideFileCache.cpp | 32 ++--- src/FileIO/RideFileCommand.cpp | 16 ++- src/FileIO/XDataDialog.cpp | 3 +- src/Gui/DiarySidebar.cpp | 7 +- src/Gui/GcCrashDialog.cpp | 2 +- src/Gui/Pages.cpp | 2 +- src/Metrics/PaceZones.cpp | 7 +- src/Metrics/RideMetadata.cpp | 8 +- src/Metrics/Zones.cpp | 7 +- src/Train/DialWindow.cpp | 3 +- 27 files changed, 201 insertions(+), 198 deletions(-) diff --git a/lmfit/lmmin.c b/lmfit/lmmin.c index 48ce82a06..37731cc63 100644 --- a/lmfit/lmmin.c +++ b/lmfit/lmmin.c @@ -235,7 +235,7 @@ void lmmin( if( C->verbosity&2 ) lm_print_pars(nout, x, msgfile); (*evaluate)(x, m, data, fvec, &(S->userbreak)); - if( C->verbosity&8 ) + if( C->verbosity&8 ){ if (y) for( i=0; infev = 1; if ( S->userbreak ) goto terminate; @@ -461,7 +462,7 @@ void lmmin( /* ratio of actual to predicted reduction */ ratio = prered ? actred/prered : 0; - if( C->verbosity&32 ) + if( C->verbosity&32 ){ if (y) for( i=0; iverbosity&2 ) { printf("%3i %2i %9.2g %9.2g %9.2g %14.6g" " %9.2g %10.3e %10.3e %21.15e", @@ -570,7 +572,7 @@ terminate: fprintf(msgfile, "lmmin terminates with outcome %i\n", S->outcome); if( C->verbosity&2 ) lm_print_pars(nout, x, msgfile); - if( C->verbosity&8 ) + if( C->verbosity&8 ){ if (y) for( i=0; iverbosity&2 ) fprintf(msgfile, " fnorm=%24.16g xnorm=%24.16g\n", S->fnorm, xnorm); if ( S->userbreak ) /* user-requested break */ @@ -1192,12 +1195,12 @@ double lm_enorm(const int n, const double *const x) if (s1 != 0) return x1max * sqrt(s1 + (s2 / x1max) / x1max); - else if (s2 != 0) + else if (s2 != 0) { if (s2 >= x3max) return sqrt(s2 * (1 + (x3max / s2) * (x3max * s3))); else return sqrt(x3max * ((s2 / x3max) + (x3max * s3))); - else + } else return x3max * sqrt(s3); } /*** lm_enorm. ***/ @@ -1269,12 +1272,12 @@ double lm_fnorm(const int n, const double *const x, const double *const y) if (s1 != 0) return x1max * sqrt(s1 + (s2 / x1max) / x1max); - else if (s2 != 0) + else if (s2 != 0) { if (s2 >= x3max) return sqrt(s2 * (1 + (x3max / s2) * (x3max * s3))); else return sqrt(x3max * ((s2 / x3max) + (x3max * s3))); - else + } else return x3max * sqrt(s3); } /*** lm_fnorm. ***/ diff --git a/qwt/examples/cpuplot/cpustat.cpp b/qwt/examples/cpuplot/cpustat.cpp index f9c7552ca..ddd039725 100644 --- a/qwt/examples/cpuplot/cpustat.cpp +++ b/qwt/examples/cpuplot/cpustat.cpp @@ -216,5 +216,6 @@ void CpuStat::lookUp( double values[NValues] ) const } } while( !textStream.atEnd() ); + file.close(); } } diff --git a/src/ANT/ANTChannel.cpp b/src/ANT/ANTChannel.cpp index bcb8b1368..6484e314b 100644 --- a/src/ANT/ANTChannel.cpp +++ b/src/ANT/ANTChannel.cpp @@ -1259,6 +1259,7 @@ void ANTChannel::attemptTransition(int message_id) // unassign regardless of status parent->sendMessage(ANTMessage::unassignChannel(number)); // unassign whatever we had before + // intentional fallthrough // drops through into assign channel because if the channel currently has no // assignment the unassign channel message will generate an error response not // an unassign channel response. But we don't really know what state the device diff --git a/src/Charts/CPPlot.cpp b/src/Charts/CPPlot.cpp index 51ddd9502..85612ed23 100644 --- a/src/Charts/CPPlot.cpp +++ b/src/Charts/CPPlot.cpp @@ -1507,7 +1507,7 @@ CPPlot::plotEfforts() QwtSymbol *sym = new QwtSymbol; sym->setStyle(QwtSymbol::Ellipse); - sym->setSize((dpiXFactor * rangemode) ? 4 : 6); + sym->setSize(dpiXFactor * (rangemode ? 4 : 6)); QColor col= GColor(CPOWER); col.setAlpha(128); sym->setBrush(col); diff --git a/src/Charts/CriticalPowerWindow.cpp b/src/Charts/CriticalPowerWindow.cpp index 8698c7a8a..723112382 100644 --- a/src/Charts/CriticalPowerWindow.cpp +++ b/src/Charts/CriticalPowerWindow.cpp @@ -739,6 +739,7 @@ CriticalPowerWindow::modelChanged() velo2->show(); velo3->show(); + // intentional fallthrough // and drop through into case 1 below ... case 1 : // Classic 2 param model 2-20 default (per literature) diff --git a/src/Charts/MUPlot.cpp b/src/Charts/MUPlot.cpp index 4f76ce987..edaa87e34 100644 --- a/src/Charts/MUPlot.cpp +++ b/src/Charts/MUPlot.cpp @@ -264,6 +264,7 @@ MUPlot::setModel(int model) fastHandle->attach(this); } + // intentional fallthrough case 1 : // Normal distribution { diff --git a/src/Cloud/CloudService.cpp b/src/Cloud/CloudService.cpp index d407ce07a..04f273564 100644 --- a/src/Cloud/CloudService.cpp +++ b/src/Cloud/CloudService.cpp @@ -200,6 +200,10 @@ CloudService::compressRide(RideFile*ride, QByteArray &data, QString name) } if (result == true) { + // read the ride file + jsonFile.open(QFile::ReadOnly); + data = jsonFile.readAll(); + jsonFile.close(); if (uploadCompression == zip) { // create a temp zip file @@ -211,10 +215,8 @@ CloudService::compressRide(RideFile*ride, QByteArray &data, QString name) QString zipname = zipFile.fileName(); ZipWriter writer(zipname); - // read the ride file back and add to zip file - jsonFile.open(QFile::ReadOnly); - writer.addFile(name, jsonFile.readAll()); - jsonFile.close(); + // add the ride file to the zip file + writer.addFile(name, data); writer.close(); // now read in the zipfile @@ -223,12 +225,7 @@ CloudService::compressRide(RideFile*ride, QByteArray &data, QString name) data = zip.readAll(); zip.close(); } else if (uploadCompression == gzip) { - // read the ride file - jsonFile.open(QFile::ReadOnly); - data = gCompress(jsonFile.readAll()); - } else { - jsonFile.open(QFile::ReadOnly); - data = jsonFile.readAll(); + data = gCompress(data); } } } diff --git a/src/Cloud/LocalFileStore.cpp b/src/Cloud/LocalFileStore.cpp index 94a59ee17..e254cec21 100644 --- a/src/Cloud/LocalFileStore.cpp +++ b/src/Cloud/LocalFileStore.cpp @@ -144,7 +144,6 @@ LocalFileStore::readFile(QByteArray *data, QString remotename, QString) *data = file.readAll(); file.close(); } else { - file.close(); return false; }; @@ -177,7 +176,6 @@ LocalFileStore::writeFile(QByteArray &data, QString remotename, RideFile *ride) file.write(data); file.close(); } else { - file.close(); emit writeComplete("", tr("Write to folder %1 failed").arg(path)); // required for single upload to get to an end return false; }; diff --git a/src/Cloud/WithingsDownload.cpp b/src/Cloud/WithingsDownload.cpp index d8a8a3e2e..8f2df8770 100644 --- a/src/Cloud/WithingsDownload.cpp +++ b/src/Cloud/WithingsDownload.cpp @@ -115,7 +115,7 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, (!strToken.isEmpty() &&! strSecret.isEmpty() && strToken != "" && strToken != "0" && strSecret != "" && strSecret != "0" )) { - printd("OAuth 2.0 API"); + printd("OAuth 2.0 API\n"); #if QT_VERSION > 0x050000 QUrlQuery postData; @@ -140,12 +140,12 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, QNetworkRequest request(url); request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); nam->post(request, postData.toString(QUrl::FullyEncoded).toUtf8()); - printd("url %s %s", url.toString().toStdString().c_str(), postData.toString().toStdString().c_str()); + printd("url %s %s\n", url.toString().toStdString().c_str(), postData.toString().toStdString().c_str()); // blocking request loop.exec(); // we go on after receiving the data in SLOT(onRequestReady(QByteArray)) - printd("response: %s", response.toStdString().c_str()); + printd("response: %s\n", response.toStdString().c_str()); if (response.contains("\"access_token\"", Qt::CaseInsensitive)) @@ -180,7 +180,7 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, QUrl url = QUrl( "https://api.health.nokia.com/measure?" + params.toString() ); - printd("URL: %s", url.url().toStdString().c_str()); + printd("URL: %s\n", url.url().toStdString().c_str()); QNetworkRequest request(url); //request.setRawHeader("Authorization", QString("Bearer %1").arg(access_token).toLatin1()); @@ -201,7 +201,7 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, if(access_token.isEmpty() && !strToken.isEmpty() &&! strSecret.isEmpty() && strToken != "" && strToken != "0" && strSecret != "" && strSecret != "0" ) { - printd("OAuth 1.0 API"); + printd("OAuth 1.0 API\n"); #ifdef GC_HAVE_KQOAUTH oauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest, QUrl("http://wbsapi.withings.net/measure")); @@ -249,7 +249,7 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, params2.addQueryItem("enddate", QString::number(to.toMSecsSinceEpoch()/1000)); QUrl url = QUrl( "https://wbsapi.withings.net/measure?" + params2.toString() ); - printd("URL : ", url.url().toStdString().c_str()); + printd("URL : %s\n", url.url().toStdString().c_str()); emit downloadStarted(100); @@ -265,7 +265,7 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, emit downloadEnded(100); #endif } else if (access_token.isEmpty()) { - printd("Withings password API"); + printd("Withings password API\n"); // account for trailing slash, remove it if it is there (it was the default in preferences) QString server = appsettings->cvalue(context->athlete->cyclist, GC_WIURL, "http://wbsapi.withings.net").toString(); @@ -292,7 +292,7 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, } } - printd("response: %s", response.toStdString().c_str()); + printd("response: %s\n", response.toStdString().c_str()); QJsonParseError parseResult; if (response.contains("\"status\":0", Qt::CaseInsensitive)) @@ -415,12 +415,12 @@ WithingsDownload::downloadFinished(QNetworkReply *reply) #ifdef GC_HAVE_KQOAUTH void WithingsDownload::onAuthorizedRequestDone() { - // printd("Request sent to Withings!"); + // printd("Request sent to Withings!\n"); } void WithingsDownload::onRequestReady(QByteArray r) { - //printd("Response from the Withings's service: %s", response..toStdString().c_str()); + //printd("Response from the Withings's service: %s\n", response..toStdString().c_str()); response = r; loop.exit(0); diff --git a/src/Cloud/Xert.cpp b/src/Cloud/Xert.cpp index f0c820fae..8e2675f33 100644 --- a/src/Cloud/Xert.cpp +++ b/src/Cloud/Xert.cpp @@ -210,7 +210,6 @@ Xert::readdir(QString path, QStringList &errors, QDateTime from, QDateTime to) // get the data QByteArray r = reply->readAll(); - int received = 0; printd("page : %s\n", r.toStdString().c_str()); // parse JSON payload @@ -221,7 +220,6 @@ Xert::readdir(QString path, QStringList &errors, QDateTime from, QDateTime to) if (parseError.error == QJsonParseError::NoError) { QJsonArray activities = document.object()["activities"].toArray(); - received = activities.count(); for(int i=0; i &data) { data.append(m); } + file.close(); return true; } diff --git a/src/Core/DataFilter.cpp b/src/Core/DataFilter.cpp index f6f754d7f..65aa7c118 100644 --- a/src/Core/DataFilter.cpp +++ b/src/Core/DataFilter.cpp @@ -149,8 +149,6 @@ DataFilter::builtins() for(int i=0; DataFilterFunctions[i].parameters != -1; i++) { - QString function; - if (i == 30) { // special case 'estimate' we describe it foreach(QString model, pdmodels()) @@ -171,6 +169,7 @@ DataFilter::builtins() foreach (QString fieldSymbol, measures.getFieldSymbols(g)) returning << QString("measure(Date, \"%1\", \"%2\")").arg(groupSymbols[g]).arg(fieldSymbol); } else { + QString function; function = DataFilterFunctions[i].name + "("; for(int j=0; jtype) { default: case Leaf::Symbol : - return leaf->dynamic; - break; - - case Leaf::Logical : - if (leaf->op == 0) return leaf->isDynamic(leaf->lvalue.l); + return leaf->dynamic; case Leaf::UnaryOperation : - return leaf->isDynamic(leaf->lvalue.l); - break; + return leaf->isDynamic(leaf->lvalue.l); + case Leaf::Logical : + if (leaf->op == 0) + return leaf->isDynamic(leaf->lvalue.l); + // intentional fallthrough case Leaf::Operation : case Leaf::BinaryOperation : - return leaf->isDynamic(leaf->lvalue.l) || leaf->isDynamic(leaf->rvalue.l); - break; + return (leaf->isDynamic(leaf->lvalue.l) || + leaf->isDynamic(leaf->rvalue.l)); case Leaf::Function : - if (leaf->series && leaf->lvalue.l) return leaf->isDynamic(leaf->lvalue.l); - else return leaf->dynamic; - break; - break; + if (leaf->series && leaf->lvalue.l) + return leaf->isDynamic(leaf->lvalue.l); + else + return leaf->dynamic; case Leaf::Conditional : - { - return leaf->isDynamic(leaf->cond.l) || - leaf->isDynamic(leaf->lvalue.l) || - (leaf->rvalue.l && leaf->isDynamic(leaf->rvalue.l)); - break; - } + return (leaf->isDynamic(leaf->cond.l) || + leaf->isDynamic(leaf->lvalue.l) || + (leaf->rvalue.l && leaf->isDynamic(leaf->rvalue.l))); case Leaf::Script : case Leaf::Vector : return true; - break; } return false; @@ -851,8 +845,6 @@ Leaf::toString() } } break; - case Leaf::Parameters : - break; default: break; @@ -861,72 +853,79 @@ Leaf::toString() return ""; } -void Leaf::print(Leaf *leaf, int level, DataFilterRuntime *df) +void Leaf::print(int level, DataFilterRuntime *df) { qDebug()<<"LEVEL"<type) { - case Leaf::Script: qDebug()<lvalue.s; break; - case Leaf::Compound: - qDebug()<<"{"; - foreach(Leaf *p, *(leaf->lvalue.b)) print(p, level+1, df); - qDebug()<<"}"; - break; + switch(type) { + case Leaf::Script : + qDebug()<print(level+1, df); + qDebug()<<"}"; + break; - case Leaf::Float : qDebug()<<"float"<lvalue.f<dynamic; break; - case Leaf::Integer : qDebug()<<"integer"<lvalue.i<dynamic; break; - case Leaf::String : qDebug()<<"string"<<*leaf->lvalue.s<dynamic; break; - case Leaf::Symbol : { - double value=0; - if (df) value=df->symbols.value(*leaf->lvalue.n).number; - qDebug()<<"symbol"<<*leaf->lvalue.n<dynamic<op; - leaf->print(leaf->lvalue.l, level+1, df); - if (leaf->op) // nonzero ? - leaf->print(leaf->rvalue.l, level+1, df); - break; - case Leaf::Operation : qDebug()<<"cop"<op; - leaf->print(leaf->lvalue.l, level+1, df); - leaf->print(leaf->rvalue.l, level+1, df); - break; - case Leaf::UnaryOperation : qDebug()<<"uop"<op; - leaf->print(leaf->lvalue.l, level+1, df); - break; - case Leaf::BinaryOperation : qDebug()<<"bop"<op; - leaf->print(leaf->lvalue.l, level+1, df); - leaf->print(leaf->rvalue.l, level+1, df); - break; - case Leaf::Function : - if (leaf->series) { - qDebug()<<"function"<function<<"parm="<<*(leaf->series->lvalue.n); - if (leaf->lvalue.l) leaf->print(leaf->lvalue.l, level+1, df); - } else { - qDebug()<<"function"<function<<"parms:"<fparms.count(); - foreach(Leaf*l, leaf->fparms) leaf->print(l, level+1, df); - } - break; - case Leaf::Vector : qDebug()<<"vector"; - leaf->print(leaf->lvalue.l, level+1, df); - leaf->print(leaf->fparms[0], level+1, df); - leaf->print(leaf->fparms[1], level+1, df); - case Leaf::Conditional : qDebug()<<"cond"<print(leaf->cond.l, level+1, df); - leaf->print(leaf->lvalue.l, level+1, df); - if (leaf->rvalue.l) leaf->print(leaf->rvalue.l, level+1, df); + double value = (df ? df->symbols.value(*lvalue.n).number : 0); + qDebug()<<"symbol"<<*lvalue.n<fparms.count(); - foreach(Leaf*l, fparms) leaf->print(l, level+1, df); + case Leaf::Logical : + qDebug()<<"lop"<print(level+1, df); + if (op) // nonzero ? + rvalue.l->print(level+1, df); + break; + case Leaf::Operation: + qDebug()<<"cop"<print(level+1, df); + rvalue.l->print(level+1, df); + break; + case Leaf::UnaryOperation: + qDebug()<<"uop"<print(level+1, df); + break; + case Leaf::BinaryOperation: + qDebug()<<"bop"<print(level+1, df); + rvalue.l->print(level+1, df); + break; + case Leaf::Function: + if (series) { + qDebug()<<"function"<lvalue.n); + if (lvalue.l) + lvalue.l->print(level+1, df); + } else { + qDebug()<<"function"<print(level+1, df); } break; + case Leaf::Vector: + qDebug()<<"vector"; + lvalue.l->print(level+1, df); + fparms[0]->print(level+1, df); + fparms[1]->print(level+1, df); + break; + case Leaf::Conditional: + qDebug()<<"cond"<print(level+1, df); + lvalue.l->print(level+1, df); + if (rvalue.l) + rvalue.l->print(level+1, df); + break; default: break; @@ -990,7 +989,6 @@ bool Leaf::isNumber(DataFilterRuntime *df, Leaf *leaf) return true; } break; - case Leaf::Parameters : return false; break; default: return false; @@ -1274,8 +1272,8 @@ void Leaf::validateFilter(Context *context, DataFilterRuntime *df, Leaf *leaf) (leaf->function == "unset" && leaf->fparms.count() != 2)) { leaf->inerror = true; - DataFiltererrors << (leaf->function == "set" ? - QString(tr("set function needs 3 paramaters; symbol, value and expression.")) : + DataFiltererrors << (leaf->function == "set" ? + QString(tr("set function needs 3 paramaters; symbol, value and expression.")) : QString(tr("unset function needs 2 paramaters; symbol and expression."))); } else { @@ -1445,14 +1443,6 @@ void Leaf::validateFilter(Context *context, DataFilterRuntime *df, Leaf *leaf) } break; - case Leaf::Parameters : - { - // should never get here ! - DataFiltererrors << tr("internal parser error: parms"); - leaf->inerror = true; - } - break; - case Leaf::Compound : { // is this a user defined function ? @@ -1463,7 +1453,7 @@ void Leaf::validateFilter(Context *context, DataFilterRuntime *df, Leaf *leaf) } // a list of statements, the last of which is what we - // evaluate to for the purposes of filtering etc + // evaluate to for the purposes of filtering etc foreach(Leaf *p, *(leaf->lvalue.b)) validateFilter(context, df, p); } break; @@ -1624,7 +1614,7 @@ QStringList DataFilter::parseFilter(Context *context, QString query, QStringList rt.isdynamic = treeRoot->isDynamic(treeRoot); // successfully parsed, lets check semantics - //treeRoot->print(treeRoot); + //treeRoot->print(0,NULL); emit parseGood(); // clear current filter list @@ -1799,7 +1789,7 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF PMAX = zoneRange >= 0 ? m->context->athlete->zones(m->isRun)->getPmax(zoneRange) : 0; // use CP for FTP, or is it configured separately - bool useCPForFTP = (appsettings->cvalue(m->context->athlete->cyclist, + bool useCPForFTP = (appsettings->cvalue(m->context->athlete->cyclist, m->context->athlete->zones(m->isRun)->useCPforFTPSetting(), 0).toInt() == 0); if (zoneRange >= 0 && !useCPForFTP) { FTP = m->context->athlete->zones(m->isRun)->getFTP(zoneRange); @@ -2402,7 +2392,7 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF if (leaf->fparms.count() != 1) qDebug()<<"bad print."; // symbol we are setting - leaf->print(leaf->fparms[0], 0, df); + leaf->fparms[0]->print(0, df); } break; diff --git a/src/Core/DataFilter.h b/src/Core/DataFilter.h index 43d919cfa..6b8d52b5e 100644 --- a/src/Core/DataFilter.h +++ b/src/Core/DataFilter.h @@ -73,7 +73,7 @@ class Leaf { Result eval(DataFilterRuntime *df, Leaf *, float x, RideItem *m, RideFilePoint *p = NULL, const QHash *metrics=NULL, Specification spec=Specification()); // tree traversal etc - void print(Leaf *, int level, DataFilterRuntime*); // print leaf and all children + void print(int level, DataFilterRuntime*); // print leaf and all children void color(Leaf *, QTextDocument *); // update the document to match bool isDynamic(Leaf *); void validateFilter(Context *context, DataFilterRuntime *, Leaf*); // validate @@ -85,7 +85,7 @@ class Leaf { enum { none, Float, Integer, String, Symbol, Logical, Operation, BinaryOperation, UnaryOperation, Function, Conditional, Vector, Index, - Parameters, Compound, Script } type; + Compound, Script } type; union value { float f; diff --git a/src/Core/DataFilter.y b/src/Core/DataFilter.y index 3faed2fdf..b58984ce4 100644 --- a/src/Core/DataFilter.y +++ b/src/Core/DataFilter.y @@ -243,10 +243,12 @@ function_def: parms: lexpr { $$ = new Leaf(@1.first_column, @1.last_column); - $$->type = Leaf::Parameters; + $$->type = Leaf::Function; + $$->series = NULL; // not tiz/best $$->fparms << $1; } - | parms ',' lexpr { $1->fparms << $3; } + | parms ',' lexpr { $1->fparms << $3; + $1->leng = @3.last_column; } ; /* @@ -446,12 +448,11 @@ expr: $$->lvalue.l = NULL; } /* functions all have zero or more parameters */ - | symbol '(' parms ')' { /* need to convert symbol to a function */ - $1->leng = @4.last_column; - $1->type = Leaf::Function; - $1->series = NULL; // not tiz/best - $1->function = *($1->lvalue.n); - $1->fparms = $3->fparms; + | symbol '(' parms ')' { /* need to convert params to a function */ + $3->loc = @1.first_column; + $3->leng = @4.last_column; + $3->function = *($1->lvalue.n); + $$ = $3; } | symbol '(' ')' { /* need to convert symbol to function */ $1->type = Leaf::Function; diff --git a/src/Core/HrvMeasures.cpp b/src/Core/HrvMeasures.cpp index c9579e2fd..d76f3f3d0 100644 --- a/src/Core/HrvMeasures.cpp +++ b/src/Core/HrvMeasures.cpp @@ -148,6 +148,7 @@ HrvMeasureParser::unserialize(QFile &file, QList &data) { data.append(m); } + file.close(); return true; } diff --git a/src/Core/RideItem.cpp b/src/Core/RideItem.cpp index 63b4d0fbe..bede59073 100644 --- a/src/Core/RideItem.cpp +++ b/src/Core/RideItem.cpp @@ -97,32 +97,34 @@ RideItem::setFrom(RideItem&here, bool temp) // used when loading cache/rideDB.js // don't update the interval pointers if this is a // temporary "fake" rideitem. - if (!temp) foreach(IntervalItem *p, intervals_) p->rideItem_ = this; + if (!temp) + foreach(IntervalItem *p, intervals_) + p->rideItem_ = this; - context = here.context; - isdirty = here.isdirty; + context = here.context; + isdirty = here.isdirty; isstale = here.isstale; - isedit = here.isedit; - skipsave = here.skipsave; + isedit = here.isedit; + skipsave = here.skipsave; if (planned == false) path = here.path; - fileName = here.fileName; - dateTime = here.dateTime; + fileName = here.fileName; + dateTime = here.dateTime; zoneRange = here.zoneRange; hrZoneRange = here.hrZoneRange; paceZoneRange = here.paceZoneRange; - fingerprint = here.fingerprint; - metacrc = here.metacrc; + fingerprint = here.fingerprint; + metacrc = here.metacrc; crc = here.crc; - timestamp = here.timestamp; - dbversion = here.dbversion; - udbversion = here.udbversion; - color = here.color; - present = here.present; + timestamp = here.timestamp; + dbversion = here.dbversion; + udbversion = here.udbversion; + color = here.color; + present = here.present; isRun = here.isRun; isSwim = here.isSwim; - weight = here.weight; - overrides_ = here.overrides_; + weight = here.weight; + overrides_ = here.overrides_; samples = here.samples; } @@ -1433,6 +1435,7 @@ RideItem::updateIntervals() } } out << "STOP" << QDateTime::currentDateTime().toString() + "\r\n"; + log.close(); } diff --git a/src/FileIO/BinRideFile.cpp b/src/FileIO/BinRideFile.cpp index 7f1c10adb..785846dd0 100644 --- a/src/FileIO/BinRideFile.cpp +++ b/src/FileIO/BinRideFile.cpp @@ -681,7 +681,7 @@ struct BinFileReaderState default: for (int i = 0; i < field.size; ++i) read_byte(&bytes_read,&sum); - errors << QString("unsupported field size %1").arg(field.size); + errors << QString("unsupported field size %1").arg(field.size); } values.push_back(v); //printf("- %d : %d\n", field.id, v); diff --git a/src/FileIO/RideFileCache.cpp b/src/FileIO/RideFileCache.cpp index 52be7777f..9c6224ab1 100644 --- a/src/FileIO/RideFileCache.cpp +++ b/src/FileIO/RideFileCache.cpp @@ -205,22 +205,22 @@ static long offsetForMeanMax(RideFileCacheHeader head, RideFile::SeriesType seri long offset = 0; switch (series) { - case RideFile::aPowerKg : offset += head.aPowerMeanMaxCount * sizeof(float); - case RideFile::aPower : offset += head.vamMeanMaxCount * sizeof(float); - case RideFile::vam : offset += head.npMeanMaxCount * sizeof(float); - case RideFile::IsoPower : offset += head.xPowerMeanMaxCount * sizeof(float); - case RideFile::xPower : offset += head.kphMeanMaxCount * sizeof(float); - case RideFile::hrd : offset += head.hrdMeanMaxCount * sizeof(float); - case RideFile::nmd : offset += head.nmdMeanMaxCount * sizeof(float); - case RideFile::cadd : offset += head.caddMeanMaxCount * sizeof(float); - case RideFile::wattsd : offset += head.wattsdMeanMaxCount * sizeof(float); - case RideFile::kphd : offset += head.kphdMeanMaxCount * sizeof(float); - case RideFile::kph : offset += head.nmMeanMaxCount * sizeof(float); - case RideFile::nm : offset += head.cadMeanMaxCount * sizeof(float); - case RideFile::cad : offset += head.hrMeanMaxCount * sizeof(float); - case RideFile::hr : offset += head.wattsKgMeanMaxCount * sizeof(float); - case RideFile::wattsKg : offset += head.wattsMeanMaxCount * sizeof(float); - case RideFile::watts : offset += 0; + case RideFile::aPowerKg : offset += head.aPowerMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::aPower : offset += head.vamMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::vam : offset += head.npMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::IsoPower : offset += head.xPowerMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::xPower : offset += head.kphMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::hrd : offset += head.hrdMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::nmd : offset += head.nmdMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::cadd : offset += head.caddMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::wattsd : offset += head.wattsdMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::kphd : offset += head.kphdMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::kph : offset += head.nmMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::nm : offset += head.cadMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::cad : offset += head.hrMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::hr : offset += head.wattsKgMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::wattsKg : offset += head.wattsMeanMaxCount * sizeof(float); // intentional fallthrough + case RideFile::watts : offset += 0; // intentional fallthrough default: break; } diff --git a/src/FileIO/RideFileCommand.cpp b/src/FileIO/RideFileCommand.cpp index 4c6fa14e2..ec078130d 100644 --- a/src/FileIO/RideFileCommand.cpp +++ b/src/FileIO/RideFileCommand.cpp @@ -638,11 +638,13 @@ SetXDataPointValueCommand::doCommand() if (series && !doubles_equal(oldvalue, newvalue)) { switch(col){ case 0: - series->datapoints[row]->secs = newvalue; + series->datapoints[row]->secs = newvalue; + break; case 1: - series->datapoints[row]->km = newvalue; + series->datapoints[row]->km = newvalue; + break; default: - series->datapoints[row]->number[col-2] = newvalue; + series->datapoints[row]->number[col-2] = newvalue; } } return true; @@ -654,11 +656,13 @@ SetXDataPointValueCommand::undoCommand() if (series && !doubles_equal(oldvalue, newvalue)) { switch(col){ case 0: - series->datapoints[row]->secs = oldvalue; + series->datapoints[row]->secs = oldvalue; + break; case 1: - series->datapoints[row]->km = oldvalue; + series->datapoints[row]->km = oldvalue; + break; default: - series->datapoints[row]->number[col-2] = oldvalue; + series->datapoints[row]->number[col-2] = oldvalue; } } return true; diff --git a/src/FileIO/XDataDialog.cpp b/src/FileIO/XDataDialog.cpp index 249186d74..4da6be1b3 100644 --- a/src/FileIO/XDataDialog.cpp +++ b/src/FileIO/XDataDialog.cpp @@ -299,9 +299,10 @@ void XDataSettingsDialog::okClicked() series.valuename.clear(); for(int i=0; i<8; i++) { - if (xdataSeriesName[i]->text() != "") + if (xdataSeriesName[i]->text() != "") { series.valuename << xdataSeriesName[i]->text(); series.unitname << xdataUnitName[i]->text(); + } } if (series.valuename.count() >0) accept(); diff --git a/src/Gui/DiarySidebar.cpp b/src/Gui/DiarySidebar.cpp index b92573db6..274d54d53 100644 --- a/src/Gui/DiarySidebar.cpp +++ b/src/Gui/DiarySidebar.cpp @@ -85,12 +85,7 @@ DiarySidebar::DiarySidebar(Context *context) : context(context) void DiarySidebar::configChanged(qint32) { - // GCColor stylesheet is too generic, we ONLY want to style the container - // and NOT its children. This is why stylesheets on widgets is a stoopid idea - QColor bgColor = GColor(CPLOTBACKGROUND); - QColor fgColor = GCColor::invertColor(bgColor); - - // now apply + // apply multiCalendar->refresh(); // and summary .. forgetting what we already prepared diff --git a/src/Gui/GcCrashDialog.cpp b/src/Gui/GcCrashDialog.cpp index 46f2c2ebe..30dab472a 100644 --- a/src/Gui/GcCrashDialog.cpp +++ b/src/Gui/GcCrashDialog.cpp @@ -540,6 +540,6 @@ GcCrashDialog::saveAs() out << report->page()->mainFrame()->toPlainText(); #endif + file.close(); } - file.close(); } diff --git a/src/Gui/Pages.cpp b/src/Gui/Pages.cpp index ed7be8503..3bb92712f 100644 --- a/src/Gui/Pages.cpp +++ b/src/Gui/Pages.cpp @@ -1758,7 +1758,7 @@ HrvPage::rangeEdited() if (dateTime == odateTime && (nrmssd != ormssd || nhr != ohr || navnn != oavnn || - sdnn != sdnn || + nsdnn != osdnn || npnn50 != opnn50 || nlf != olf || nhf != ohf || diff --git a/src/Metrics/PaceZones.cpp b/src/Metrics/PaceZones.cpp index e3144c218..056aca7d9 100644 --- a/src/Metrics/PaceZones.cpp +++ b/src/Metrics/PaceZones.cpp @@ -185,8 +185,9 @@ bool PaceZones::read(QFile &file) QString line = fileStream.readLine(); int pos = commentrx.indexIn(line, 0); if (pos != -1) - line = line.left(pos); if (blankrx.indexIn(line, 0) == 0) - goto next_line; + line = line.left(pos); + if (blankrx.indexIn(line, 0) == 0) + continue; // check for default zone range definition (may be followed by zone definitions) if (zonedefaultsx.indexIn(line, 0) != -1) { zones_are_defaults = true; @@ -203,7 +204,7 @@ bool PaceZones::read(QFile &file) return false; } - goto next_line; + continue; } // check for range specification (may be followed by zone definitions) diff --git a/src/Metrics/RideMetadata.cpp b/src/Metrics/RideMetadata.cpp index a24475d1e..086454191 100644 --- a/src/Metrics/RideMetadata.cpp +++ b/src/Metrics/RideMetadata.cpp @@ -608,10 +608,12 @@ FormField::~FormField() switch (definition.type) { case FIELD_TEXT: - case FIELD_SHORTTEXT: if (definition.name == "Keywords") + case FIELD_SHORTTEXT: + if (definition.name == "Keywords") delete (QLineEdit*)widget; - if (completer) delete completer; - break; + if (completer) + delete completer; + break; case FIELD_TEXTBOX : if (definition.name == "Summary") delete ((RideSummaryWindow *)widget); else diff --git a/src/Metrics/Zones.cpp b/src/Metrics/Zones.cpp index 975eff176..7caa9a527 100644 --- a/src/Metrics/Zones.cpp +++ b/src/Metrics/Zones.cpp @@ -151,8 +151,9 @@ bool Zones::read(QFile &file) QString line = fileStream.readLine(); int pos = commentrx.indexIn(line, 0); if (pos != -1) - line = line.left(pos); if (blankrx.indexIn(line, 0) == 0) - goto next_line; + line = line.left(pos); + if (blankrx.indexIn(line, 0) == 0) + continue; // check for default zone range definition (may be followed by zone definitions) if (zonedefaultsx.indexIn(line, 0) != -1) { zones_are_defaults = true; @@ -169,7 +170,7 @@ bool Zones::read(QFile &file) return false; } - goto next_line; + continue; } // check for range specification (may be followed by zone definitions) diff --git a/src/Train/DialWindow.cpp b/src/Train/DialWindow.cpp index 1214e6f33..853c26837 100644 --- a/src/Train/DialWindow.cpp +++ b/src/Train/DialWindow.cpp @@ -248,7 +248,8 @@ DialWindow::telemetryUpdate(const RealtimeData &rtData) valueLabel->setText("N/A"); break; } - // intentional fall-through to standard distance rendering + // intentional fall-through + // to standard distance rendering case RealtimeData::Distance: case RealtimeData::LapDistance: