diff --git a/src/Metrics/RideMetadata.cpp b/src/Metrics/RideMetadata.cpp index 3e698c1ab..a512307ae 100644 --- a/src/Metrics/RideMetadata.cpp +++ b/src/Metrics/RideMetadata.cpp @@ -252,15 +252,22 @@ RideMetadata::configChanged(qint32) // this was changed to be global configuration since other global // settings are dependant on them, notably user metrics bool first=true; + bool addDefault=true; QStringListIterator i(QDir(gcroot).entryList(QDir::Dirs | QDir::NoDotAndDotDot)); - while (i.hasNext()) { - - QString name = i.next(); + while (i.hasNext() || addDefault) { + QString filename; + if (i.hasNext()) { + // add athlete setup + filename = gcroot + "/" + i.next() + "/config/metadata.xml"; + } else { + // add the default setup + filename = ":/xml/metadata.xml"; + addDefault = false; + } // if there is no metadata.xml it is not an athlete folder // or it is one still using default metadata.xml, so skip it // since there is no custom configuration to preserve. - QString filename = gcroot + "/" + name + "/config/metadata.xml"; if (!QFile(filename).exists()) continue; // athlete specific configuration @@ -323,14 +330,6 @@ RideMetadata::configChanged(qint32) } } - // eek, we didn't find anything - new install with no athletes yet - if (first == true) { - - // use the default setup - filename = ":/xml/metadata.xml"; - readXML(filename, keywordDefinitions, fieldDefinitions, colorfield, defaultDefinitions); - } - // write out global file now, so we don't keep doing this // "upgrade" process every time we open an athlete etc filename = QDir(gcroot).absolutePath()+"/metadata.xml";