Novae.cpp   Novae.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(novaeJsonPath).exists()) if(QFileInfo(novaeJsonPath).exists())
{ {
if (getJsonFileVersion() < CATALOG_FORMAT_VERSION) if (!checkJsonFileFormat() || getJsonFileVersion()<CATALOG_F ORMAT_VERSION)
{ {
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
} }
else else
{ {
qDebug() << "Novae::init novae.json does not exist - copying default file to " << QDir::toNativeSeparators(novaeJsonPath); qDebug() << "Novae::init novae.json does not exist - copying default file to " << QDir::toNativeSeparators(novaeJsonPath);
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
skipping to change at line 530 skipping to change at line 530
if (map.contains("version")) if (map.contains("version"))
{ {
jsonVersion = map.value("version").toInt(); jsonVersion = map.value("version").toInt();
} }
novaeJsonFile.close(); novaeJsonFile.close();
qDebug() << "Novae::getJsonFileVersion() version from file:" << json Version; qDebug() << "Novae::getJsonFileVersion() version from file:" << json Version;
return jsonVersion; return jsonVersion;
} }
bool Novae::checkJsonFileFormat()
{
QFile novaeJsonFile(novaeJsonPath);
if (!novaeJsonFile.open(QIODevice::ReadOnly))
{
qWarning() << "Novae::checkJsonFileFormat(): cannot open " <
< QDir::toNativeSeparators(novaeJsonPath);
return false;
}
QVariantMap map;
try
{
map = StelJsonParser::parse(&novaeJsonFile).toMap();
novaeJsonFile.close();
}
catch (std::runtime_error& e)
{
qDebug() << "Novae::checkJsonFileFormat(): file format is wr
ong!";
qDebug() << "Novae::checkJsonFileFormat() error:" << e.what(
);
return false;
}
return true;
}
NovaP Novae::getByID(const QString& id) NovaP Novae::getByID(const QString& id)
{ {
foreach(const NovaP& n, nova) foreach(const NovaP& n, nova)
{ {
if (n->initialized && n->designation == id) if (n->initialized && n->designation == id)
return n; return n;
} }
return NovaP(); return NovaP();
} }
 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/