Fixed masterlist update roll-back causing issues.

Like the UI not being updated, because the updater function was exiting
early.
This commit is contained in:
WrinklyNinja
2014-08-20 10:22:44 +01:00
parent 66b34f1153
commit e8088e2770
2 changed files with 19 additions and 2 deletions
+1 -1
View File
@@ -442,7 +442,7 @@ namespace loot {
git.call(git_checkout_head(git.repo, &checkout_opts));
if (parsingError.empty())
parsingError = boost::locale::translate("Masterlist revision").str() + " " + string(revision) + ": " + e.what() + " " + boost::locale::translate("Rolled back to the previous revision.").str();
parsingError = boost::locale::translate("Masterlist revision").str() + " " + string(revision) + ": " + e.what() + ". " + boost::locale::translate("Rolled back to the previous revision.").str();
}
} while (parsingFailed);
+18 -1
View File
@@ -686,6 +686,7 @@ namespace loot {
std::string Handler::UpdateMasterlist() {
BOOST_LOG_TRIVIAL(debug) << "Updating and parsing masterlist.";
string parsingError;
//Set language.
unsigned int language;
@@ -696,7 +697,18 @@ namespace loot {
BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(language).Name();
// Update / parse masterlist.
g_app_state.CurrentGame().masterlist.Load(g_app_state.CurrentGame(), language);
try {
g_app_state.CurrentGame().masterlist.Load(g_app_state.CurrentGame(), language);
}
catch (loot::error &e) {
if (e.code() == loot::error::ok) {
// There was a parsing error, but roll-back was successful, so the process
// should still complete.
parsingError = e.what();
}
else
throw e;
}
// Now regenerate the JS-side masterlist data.
@@ -751,6 +763,11 @@ namespace loot {
messages.push_back(Message(Message::error, (format(loc::translate("A global message contains a condition that could not be evaluated. Details: %1%")) % e.what()).str()));
}
// Add the parsing error to the global messages, if it exists.
if (!parsingError.empty()) {
messages.push_back(Message(Message::error, parsingError));
}
// Now store global messages from masterlist.
gameNode["globalMessages"] = messages;