QTfrontend/ui/page/pagetraining.cpp
changeset 6167 728cabee2c9f
parent 6160 863d3edf5690
child 6183 46895724fd7f
equal deleted inserted replaced
6166:701c5b8fac56 6167:728cabee2c9f
   121 
   121 
   122     QString loc = settings.value("misc/locale", "").toString();
   122     QString loc = settings.value("misc/locale", "").toString();
   123     if (loc.isEmpty())
   123     if (loc.isEmpty())
   124         loc = QLocale::system().name();
   124         loc = QLocale::system().name();
   125 
   125 
   126     QFile * infoFile = HWDataManager::instance().findFileForRead(
   126     QString infoFile = HWDataManager::instance().findFileForRead(
   127                                     QString("Locale/missions_" + loc + ".txt"));
   127                             QString("Locale/missions_" + loc + ".txt"));
   128 
   128 
   129     // if file is non-existant try with language only
   129     // if file is non-existant try with language only
   130     if (!infoFile->exists())
   130     if (!QFile::exists(infoFile))
   131     {
       
   132         delete infoFile;
       
   133         infoFile = HWDataManager::instance().findFileForRead(QString(
   131         infoFile = HWDataManager::instance().findFileForRead(QString(
   134                 "Locale/missions_" + loc.remove(QRegExp("_.*$")) + ".txt"));
   132                 "Locale/missions_" + loc.remove(QRegExp("_.*$")) + ".txt"));
   135     }
       
   136 
   133 
   137     // fallback if file for current locale is non-existant
   134     // fallback if file for current locale is non-existant
   138     if (!infoFile->exists())
   135     if (!QFile::exists(infoFile))
   139     {
   136     {
   140         delete infoFile;
       
   141         infoFile = HWDataManager::instance().findFileForRead(
   137         infoFile = HWDataManager::instance().findFileForRead(
   142                                             QString("Locale/missions_en.txt"));
   138                                             QString("Locale/missions_en.txt"));
   143     }
   139     }
   144 
   140 
   145 
   141 
   146     // preload mission info for current locale
   142     // preload mission info for current locale
   147     m_info =
   143     m_info = new QSettings(infoFile, QSettings::IniFormat, this);
   148         new QSettings(infoFile->fileName(), QSettings::IniFormat, this);
   144 
   149 
       
   150     // this QFile isn't needed any further
       
   151     delete infoFile;
       
   152 
   145 
   153     QStringList missionList =
   146     QStringList missionList =
   154             HWDataManager::instance().entryList(
   147             HWDataManager::instance().entryList(
   155                                                 "Missions/Training",
   148                                                 "Missions/Training",
   156                                                 QDir::Files,
   149                                                 QDir::Files,