Skip to content

Commit

Permalink
Make the GPX output locale-independent
Browse files Browse the repository at this point in the history
As required by the GPX schema (specifically xsd:decimal).

Once this trickles down to v800_downloader, this should also resolve
profanum429/v800_downloader#23

Note, this is effectively a squashed merge of the locale branch.
  • Loading branch information
pcolby committed Aug 22, 2016
1 parent 3147b54 commit af7e80d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ after_build:
test_script:
- cd %APPVEYOR_BUILD_FOLDER%-build
- if not %CONFIGURATION%==debug %make% check TESTARGS=-silent
- if %QTDIR:msvc=%==%QTDIR% ( set "BIPOLAR_TEST_LOCALE=german" ) else set "BIPOLAR_TEST_LOCALE=de-DE"
- if not %CONFIGURATION%==debug %make% check TESTARGS=-silent

artifacts:
- path: Bipolar.exe
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ before_script:
script:
- make -C "$TRAVIS_BUILD_DIR-build" -j2 all
- make -C "$TRAVIS_BUILD_DIR-build" -j2 check
- BIPOLAR_TEST_LOCALE=de_DE.UTF-8 make -C "$TRAVIS_BUILD_DIR-build" -j2 check
- '[ "$TRAVIS_OS_NAME" != osx ] || make -C "$TRAVIS_BUILD_DIR-build/pkg/osx" dmg'

deploy:
Expand Down
4 changes: 2 additions & 2 deletions src/polar/v2/trainingsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1474,8 +1474,8 @@ QDomDocument TrainingSession::toGPX(const QDateTime &creationTime) const
}

QDomElement trkpt = doc.createElement(QLatin1String("trkpt"));
trkpt.setAttribute(QLatin1String("lat"), latitude.at(index).toDouble());
trkpt.setAttribute(QLatin1String("lon"), longitude.at(index).toDouble());
trkpt.setAttribute(QLatin1String("lat"), VARIANT_TO_STRING(latitude.at(index)));
trkpt.setAttribute(QLatin1String("lon"), VARIANT_TO_STRING(longitude.at(index)));
trkpt.appendChild(doc.createElement(QLatin1String("ele")))
.appendChild(doc.createTextNode(VARIANT_TO_STRING(altitude.at(index))));
trkpt.appendChild(doc.createElement(QLatin1String("time")))
Expand Down
14 changes: 14 additions & 0 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <QTest>

#include <locale.h>
#include <stdio.h>

typedef QObject * (*ObjectConstructor)();
Expand Down Expand Up @@ -53,6 +54,19 @@ int main(int argc, char *argv[]) {
app.setApplicationVersion(QLatin1String("1.2.3.4"));
app.setAttribute(Qt::AA_Use96Dpi, true);

// If the BIPOLAR_TEST_LOCALE environment variable is set, then set this
// test application's locale accordingly. The same can be done other ways,
// but its near impossible to acheive externally on AppVeyor, and at least
// here we get to bail if the setlocale call fails.
const QByteArray locale = qgetenv("BIPOLAR_TEST_LOCALE");
if (!locale.isEmpty()) {
if (setlocale(LC_ALL, locale.data()) == NULL) {
fprintf(stderr, "failed to set locale '%s'\n", locale.data());
return EXIT_FAILURE;
}
fprintf(stdout, "set locale '%s'\n", locale.data());
}

// Setup our tests factory object.
ObjectFactory testFactory;
testFactory.registerClass<TestFixnum>();
Expand Down

0 comments on commit af7e80d

Please sign in to comment.