Supernovae.cpp   Supernovae.cpp 
skipping to change at line 76 skipping to change at line 76
{ {
Q_INIT_RESOURCE(Supernovae); Q_INIT_RESOURCE(Supernovae);
StelPluginInfo info; StelPluginInfo info;
info.id = "Supernovae"; info.id = "Supernovae";
info.displayedName = N_("Historical Supernovae"); info.displayedName = N_("Historical Supernovae");
info.authors = "Alexander Wolf"; info.authors = "Alexander Wolf";
info.contact = "alex.v.wolf@gmail.com"; info.contact = "alex.v.wolf@gmail.com";
info.description = N_("This plugin allows you to see some bright his torical supernovae."); info.description = N_("This plugin allows you to see some bright his torical supernovae.");
info.version = SUPERNOVAE_PLUGIN_VERSION; info.version = SUPERNOVAE_PLUGIN_VERSION;
info.license = SUPERNOVAE_PLUGIN_LICENSE;
return info; return info;
} }
/* /*
Constructor Constructor
*/ */
Supernovae::Supernovae() Supernovae::Supernovae()
: SNCount(0) : SNCount(0)
, updateState(CompleteNoUpdates) , updateState(CompleteNoUpdates)
, downloadMgr(Q_NULLPTR) , downloadMgr(Q_NULLPTR)
skipping to change at line 596 skipping to change at line 597
downloadMgr->get(request); downloadMgr->get(request);
updateState = Supernovae::CompleteUpdates; updateState = Supernovae::CompleteUpdates;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
emit(jsonUpdateComplete()); emit(jsonUpdateComplete());
} }
void Supernovae::updateDownloadComplete(QNetworkReply* reply) void Supernovae::updateDownloadComplete(QNetworkReply* reply)
{ {
// check the download worked, and save the data to file if this is t he case. // check the download worked, and save the data to file if this is t he case.
if (reply->error() != QNetworkReply::NoError) if (reply->error() == QNetworkReply::NoError && reply->bytesAvailabl
{ e()>0)
qWarning() << "[Supernovae] FAILED to download" << reply->ur
l() << " Error: " << reply->errorString();
}
else
{ {
// download completed successfully. // download completed successfully.
QString jsonFilePath = StelFileMgr::findFile("modules/Supern ovae", StelFileMgr::Flags(StelFileMgr::Writable|StelFileMgr::Directory)) + "/supernovae.json"; QString jsonFilePath = StelFileMgr::findFile("modules/Supern ovae", StelFileMgr::Flags(StelFileMgr::Writable|StelFileMgr::Directory)) + "/supernovae.json";
if (jsonFilePath.isEmpty()) if (jsonFilePath.isEmpty())
{ {
qWarning() << "[Supernovae] cannot write JSON data t o file:" << QDir::toNativeSeparators(jsonFilePath); qWarning() << "[Supernovae] cannot write JSON data t o file:" << QDir::toNativeSeparators(jsonFilePath);
return; return;
} }
QFile jsonFile(jsonFilePath); QFile jsonFile(jsonFilePath);
if (jsonFile.exists()) if (jsonFile.exists())
jsonFile.remove(); jsonFile.remove();
if(jsonFile.open(QIODevice::WriteOnly | QIODevice::Text)) if(jsonFile.open(QIODevice::WriteOnly | QIODevice::Text))
{ {
jsonFile.write(reply->readAll()); jsonFile.write(reply->readAll());
jsonFile.close(); jsonFile.close();
} }
} }
else
qWarning() << "[Supernovae] FAILED to download" << reply->ur
l() << " Error: " << reply->errorString();
if (progressBar) if (progressBar)
{ {
progressBar->setValue(100); progressBar->setValue(100);
StelApp::getInstance().removeProgressBar(progressBar); StelApp::getInstance().removeProgressBar(progressBar);
progressBar = Q_NULLPTR; progressBar = Q_NULLPTR;
} }
readJsonFile(); readJsonFile();
} }
 End of changes. 3 change blocks. 
6 lines changed or deleted 6 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/