Pulsars.cpp   Pulsars.cpp 
skipping to change at line 190 skipping to change at line 190
// 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(jsonCatalogPath).exists()) if(QFileInfo(jsonCatalogPath).exists())
{ {
if (getJsonFileFormatVersion() < CATALOG_FORMAT_VERSION) if (!checkJsonFileFormat() || getJsonFileFormatVersion()<CAT ALOG_FORMAT_VERSION)
{ {
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
} }
else else
{ {
qDebug() << "Pulsars::init pulsars.json does not exist - cop ying default file to " << QDir::toNativeSeparators(jsonCatalogPath); qDebug() << "Pulsars::init pulsars.json does not exist - cop ying default file to " << QDir::toNativeSeparators(jsonCatalogPath);
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
skipping to change at line 560 skipping to change at line 560
if (map.contains("version")) if (map.contains("version"))
{ {
jsonVersion = map.value("version").toInt(); jsonVersion = map.value("version").toInt();
} }
jsonPSRCatalogFile.close(); jsonPSRCatalogFile.close();
qDebug() << "Pulsars::getJsonFileFormatVersion() version of format f rom file:" << jsonVersion; qDebug() << "Pulsars::getJsonFileFormatVersion() version of format f rom file:" << jsonVersion;
return jsonVersion; return jsonVersion;
} }
bool Pulsars::checkJsonFileFormat()
{
QFile jsonPSRCatalogFile(jsonCatalogPath);
if (!jsonPSRCatalogFile.open(QIODevice::ReadOnly))
{
qWarning() << "Pulsars::checkJsonFileFormat(): cannot open "
<< QDir::toNativeSeparators(jsonCatalogPath);
return false;
}
QVariantMap map;
try
{
map = StelJsonParser::parse(&jsonPSRCatalogFile).toMap();
jsonPSRCatalogFile.close();
}
catch (std::runtime_error& e)
{
qDebug() << "Pulsars::checkJsonFileFormat(): file format is
wrong!";
qDebug() << "Pulsars::checkJsonFileFormat() error:" << e.wha
t();
return false;
}
return true;
}
PulsarP Pulsars::getByID(const QString& id) PulsarP Pulsars::getByID(const QString& id)
{ {
foreach(const PulsarP& pulsar, psr) foreach(const PulsarP& pulsar, psr)
{ {
if (pulsar->initialized && pulsar->designation == id) if (pulsar->initialized && pulsar->designation == id)
return pulsar; return pulsar;
} }
return PulsarP(); return PulsarP();
} }
 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/