@@ -30,7 +30,7 @@ void ApplyLibraryOverrides::downloadLibraryOverrideList()
3030
3131void ApplyLibraryOverrides::onLibraryOverrideDownloadFinished ()
3232{
33- if (m_request->error () != QNetworkReply::NoError) {
33+ if (m_request->error () != QNetworkReply::NoError || !m_response ) {
3434 emitFailed (" Failed to download EPL metadata." );
3535 return ;
3636 }
@@ -43,20 +43,20 @@ void ApplyLibraryOverrides::onLibraryOverrideDownloadFinished()
4343 }
4444
4545 bool replacedAuthlib = false ;
46- auto root = doc.object ();
47- auto overrides = root[ " overrides" ] .toObject ();
46+ const auto root = doc.object ();
47+ const QJsonObject overrides = root. value ( " overrides" ) .toObject ();
4848
4949 for (const auto &library : m_instance->getPackProfile ()->getProfile ()->getLibraries ()) {
50- const QString& artifact = library->artifactPrefix ();
51- const bool isAuthlib = artifact == " com.mojang:authlib" ;
50+ const QString& libraryArtifact = library->artifactPrefix ();
51+ const bool isAuthlib = libraryArtifact == " com.mojang:authlib" ;
5252
53- auto artifactRef = overrides[artifact] ;
54- if (!artifactRef .isObject ()) {
53+ const QJsonValue artifact = overrides. value (libraryArtifact) ;
54+ if (!artifact .isObject ()) {
5555 continue ;
5656 }
5757
58- auto versionRef = artifactRef .toObject ()[ library->version ()] ;
59- if (!versionRef .isObject ()) {
58+ const QJsonValue version = artifact .toObject (). value ( library->version ()) ;
59+ if (!version .isObject ()) {
6060 continue ;
6161 }
6262
@@ -65,14 +65,13 @@ void ApplyLibraryOverrides::onLibraryOverrideDownloadFinished()
6565 continue ;
6666 }
6767
68- auto override = versionRef .toObject ();
69- auto newDownloadInfo = std::make_shared<MojangDownloadInfo>();
70- newDownloadInfo->url = override [ " url" ] .toString ();
71- newDownloadInfo->sha1 = override [ " sha1" ] .toString ();
72- newDownloadInfo->size = override [ " size" ] .toInt ();
68+ const QJsonObject override = version .toObject ();
69+ const auto newDownloadInfo = std::make_shared<MojangDownloadInfo>();
70+ newDownloadInfo->url = override . value ( " url" ) .toString ();
71+ newDownloadInfo->sha1 = override . value ( " sha1" ) .toString ();
72+ newDownloadInfo->size = override . value ( " size" ) .toInt ();
7373
7474 const auto newLibraryInfo = std::make_shared<MojangLibraryDownloadInfo>(newDownloadInfo);
75-
7675 library->setMojangDownloadInfo (newLibraryInfo);
7776
7877 replacedAuthlib = replacedAuthlib || isAuthlib;
@@ -85,7 +84,7 @@ void ApplyLibraryOverrides::onLibraryOverrideDownloadFinished()
8584 return ;
8685 }
8786
88- downloadAuthlibInjector (root[ " extras" ] .toObject ()[ " authlib-injector" ] .toString ());
87+ downloadAuthlibInjector (root. value ( " extras" ) .toObject (). value ( " authlib-injector" ) .toString ());
8988}
9089
9190void ApplyLibraryOverrides::downloadAuthlibInjector (const QUrl &downloadUrl) {
0 commit comments