Supernovae.cpp   Supernovae.cpp 
skipping to change at line 162 skipping to change at line 162
// A timer for hiding alert messages // A timer for hiding alert messages
messageTimer = new QTimer(this); messageTimer = new QTimer(this);
messageTimer->setSingleShot(true); // recurring check for update messageTimer->setSingleShot(true); // recurring check for update
messageTimer->setInterval(9000); // 6 seconds should be enough time messageTimer->setInterval(9000); // 6 seconds should be enough time
messageTimer->stop(); messageTimer->stop();
connect(messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout() )); connect(messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout() ));
// If the json file does not already exist, create it from the resou rce in the Qt resource // If the json file does not already exist, create it from the resou rce in the Qt resource
if(QFileInfo(sneJsonPath).exists()) if(QFileInfo(sneJsonPath).exists())
{ {
if (getJsonFileVersion() < CATALOG_FORMAT_VERSION) if (!checkJsonFileFormat() || getJsonFileVersion()<CATALOG_F ORMAT_VERSION)
{ {
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
} }
else else
{ {
qDebug() << "Supernovae::init supernovae.json does not exist - copying default file to " << QDir::toNativeSeparators(sneJsonPath); qDebug() << "Supernovae::init supernovae.json does not exist - copying default file to " << QDir::toNativeSeparators(sneJsonPath);
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
skipping to change at line 513 skipping to change at line 513
if (map.contains("version")) if (map.contains("version"))
{ {
jsonVersion = map.value("version").toInt(); jsonVersion = map.value("version").toInt();
} }
sneJsonFile.close(); sneJsonFile.close();
qDebug() << "Supernovae::getJsonFileVersion() version from file:" << jsonVersion; qDebug() << "Supernovae::getJsonFileVersion() version from file:" << jsonVersion;
return jsonVersion; return jsonVersion;
} }
bool Supernovae::checkJsonFileFormat()
{
QFile sneJsonFile(sneJsonPath);
if (!sneJsonFile.open(QIODevice::ReadOnly))
{
qWarning() << "Supernovae::checkJsonFileFormat(): cannot ope
n " << QDir::toNativeSeparators(sneJsonPath);
return false;
}
QVariantMap map;
try
{
map = StelJsonParser::parse(&sneJsonFile).toMap();
sneJsonFile.close();
}
catch (std::runtime_error& e)
{
qDebug() << "Supernovae::checkJsonFileFormat(): file format
is wrong!";
qDebug() << "Supernovae::checkJsonFileFormat() error:" << e.
what();
return false;
}
return true;
}
float Supernovae::getLowerLimitBrightness() float Supernovae::getLowerLimitBrightness()
{ {
float lowerLimit = 10.f; float lowerLimit = 10.f;
QFile sneJsonFile(sneJsonPath); QFile sneJsonFile(sneJsonPath);
if (!sneJsonFile.open(QIODevice::ReadOnly)) if (!sneJsonFile.open(QIODevice::ReadOnly))
{ {
qWarning() << "Supernovae::init cannot open " << QDir::toNat iveSeparators(sneJsonPath); qWarning() << "Supernovae::init cannot open " << QDir::toNat iveSeparators(sneJsonPath);
return lowerLimit; return lowerLimit;
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 29 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/