diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-06-03 21:57:22 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-06-06 21:23:05 +0200 |
commit | 24db645167b42adba5d9c221215be83bef39e2a1 (patch) | |
tree | cb7c797d232ac428d2a03d2166762d7bd8167e4c /logic/minecraft/MinecraftVersionList.cpp | |
parent | dde35a0eb8847d6dd13219bae9648bf6c4d7b9e3 (diff) | |
download | MultiMC-24db645167b42adba5d9c221215be83bef39e2a1.tar MultiMC-24db645167b42adba5d9c221215be83bef39e2a1.tar.gz MultiMC-24db645167b42adba5d9c221215be83bef39e2a1.tar.lz MultiMC-24db645167b42adba5d9c221215be83bef39e2a1.tar.xz MultiMC-24db645167b42adba5d9c221215be83bef39e2a1.zip |
NOISSUE sanitize Json
Removes magical parameter madness.
All require* can throw
All ensure* need a default value and never throw
Diffstat (limited to 'logic/minecraft/MinecraftVersionList.cpp')
-rw-r--r-- | logic/minecraft/MinecraftVersionList.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp index 44be281b..8ba51b99 100644 --- a/logic/minecraft/MinecraftVersionList.cpp +++ b/logic/minecraft/MinecraftVersionList.cpp @@ -157,11 +157,11 @@ void MinecraftVersionList::loadBuiltinList() qDebug() << "Loading builtin version list."; // grab the version list data from internal resources. const QJsonDocument doc = - Json::ensureDocument(QString(":/versions/minecraft.json"), "builtin version list"); + Json::requireDocument(QString(":/versions/minecraft.json"), "builtin version list"); const QJsonObject root = doc.object(); // parse all the versions - for (const auto version : Json::ensureArray(root.value("versions"))) + for (const auto version : Json::requireArray(root.value("versions"))) { QJsonObject versionObj = version.toObject(); QString versionID = versionObj.value("id").toString(""); @@ -203,9 +203,9 @@ void MinecraftVersionList::loadBuiltinList() mcVersion->m_processArguments = versionObj.value("processArguments").toString("legacy"); if (versionObj.contains("+traits")) { - for (auto traitVal : Json::ensureArray(versionObj.value("+traits"))) + for (auto traitVal : Json::requireArray(versionObj.value("+traits"))) { - mcVersion->m_traits.insert(Json::ensureString(traitVal)); + mcVersion->m_traits.insert(Json::requireString(traitVal)); } } m_lookup[versionID] = mcVersion; @@ -226,9 +226,9 @@ void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource s try { - QJsonObject latest = Json::ensureObject(root.value("latest")); - m_latestReleaseID = Json::ensureString(latest.value("release")); - m_latestSnapshotID = Json::ensureString(latest.value("snapshot")); + QJsonObject latest = Json::requireObject(root.value("latest")); + m_latestReleaseID = Json::requireString(latest.value("release")); + m_latestSnapshotID = Json::requireString(latest.value("snapshot")); } catch (Exception &err) { |