Index: sources/storage/Settings.cpp =================================================================== diff -u -r689177edf29dee6f10bebfed42f6bbadeb7ce8a8 -r9febb7ea48512fb5cee8006a93e7cf030c86815d --- sources/storage/Settings.cpp (.../Settings.cpp) (revision 689177edf29dee6f10bebfed42f6bbadeb7ce8a8) +++ sources/storage/Settings.cpp (.../Settings.cpp) (revision 9febb7ea48512fb5cee8006a93e7cf030c86815d) @@ -52,33 +52,36 @@ /*! * \brief Settings::doRead * \details Reads all the configuration files + * \return non-zero, error value on error, and zero on success. */ int Settings::read() { - int err = Settings::Settings_Error::eError_None; + int err = Settings::Settings_Error::eError_None; QStringList fileFilter = QStringList() << QString("*.%1").arg(_settingsExt); QFileInfoList settingFiles = FileHandler::find (Storage::Settings_Path(), fileFilter); QStringList settingFolders = FileHandler::subFolders(Storage::Settings_Path()); if ( ! settingFolders.count() ) { err = Settings::Settings_Error::eError_No_SettingsFolder; - LOG_DEBUG(errorMessage(err).arg(Storage::Settings_Path())); + LOG_APPED_PO(errorMessage(err).arg(Storage::Settings_Path())); return err; } for ( QString &settingFolder : settingFolders ) { QString folder = settingFolder.prepend(Storage::Settings_Path()); settingFiles += FileHandler::find(folder, fileFilter); } + // DEBUG: // settingFiles = // { // QFileInfo("/home/denali/Projects/application/resources/settings/Confirm/Confirm.conf"), // QFileInfo("/home/denali/Projects/application/resources/settings/Alarms/Alarms.conf") // }; + if ( ! settingFiles.count() ) { err = Settings::Settings_Error::eError_No_SettingsFile; - LOG_DEBUG(errorMessage(err).arg(Storage::Settings_Path())); + LOG_APPED_PO(errorMessage(err).arg(Storage::Settings_Path())); return err; } @@ -87,14 +90,24 @@ if (! isValid(settingFile.absoluteFilePath())) continue; QFile file(settingFile.absoluteFilePath()); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - Detail detail; - detail.content = file.readAll().trimmed(); - if (detail.content.isEmpty()) continue; - detail.location = settingFile.absolutePath() + "/"; - detail.category = QString(detail.location + settingFile.baseName()).remove(Storage::Settings_Path()); - details += detail; + if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) { + err = Settings::Settings_Error::eError_Read; + LOG_APPED_PO(errorMessage(err).arg(Storage::Settings_Path())); + return err; } + + Detail detail; + detail.content = file.readAll().trimmed(); + if (detail.content.isEmpty()) { + //TODO Do not error out for now, the list of the config files which can be empty or not needs to be defined. + // err = Settings::Settings_Error::eError_Empty; + LOG_APPED_PO(errorMessage(Settings::Settings_Error::eError_Empty).arg(settingFile.fileName())); + continue; + } + + detail.location = settingFile.absolutePath() + "/"; + detail.category = QString(detail.location + settingFile.baseName()).remove(Storage::Settings_Path()); + details += detail; } for (const auto &detail : details) { @@ -125,7 +138,7 @@ else if ( line == attribute.arg(_duplicate_key_off ) ) { enableDuplicateKey = false ;} else { - LOG_APPED_UI(( "Unknown '" + line + "' attribute in %1").arg(detail.category)); + LOG_APPED_PO(( "Unknown '" + line + "' attribute in %1").arg(detail.category)); } }