Fixed crash on invalid curseforge link on import

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2024-04-07 21:25:08 +03:00
parent 70f7e0878e
commit 9cc58fe62c
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318

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>();