Merge pull request #2291 from Trial97/import_crash

Fixed crash on invalid curseforge link on import
This commit is contained in:
Alexandru Ionut Tripon 2024-04-09 00:19:55 +03:00 committed by GitHub
commit 1a994e8aed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -123,6 +123,10 @@ void ImportPage::updateState()
// need to find the download link for the modpack // need to find the download link for the modpack
// format of url curseforge://install?addonId=IDHERE&fileId=IDHERE // format of url curseforge://install?addonId=IDHERE&fileId=IDHERE
QUrlQuery query(url); QUrlQuery query(url);
if (query.allQueryItemValues("addonId").isEmpty() || query.allQueryItemValues("fileId").isEmpty()) {
qDebug() << "Invalid curseforge link:" << url;
return;
}
auto addonId = query.allQueryItemValues("addonId")[0]; auto addonId = query.allQueryItemValues("addonId")[0];
auto fileId = query.allQueryItemValues("fileId")[0]; auto fileId = query.allQueryItemValues("fileId")[0];
auto array = std::make_shared<QByteArray>(); auto array = std::make_shared<QByteArray>();