[Backport release-11.x] fix: ignore non-existent or empty paths in processURLs (#5515)

This commit is contained in:
Alexandru Ionut Tripon 2026-05-07 21:42:17 +03:00 committed by GitHub
commit 0cbeb93939
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -931,6 +931,9 @@ void MainWindow::processURLs(QList<QUrl> urls)
{
// NOTE: This loop only processes one dropped file!
for (auto& url : urls) {
if (url.isEmpty() || url.toString().trimmed().isEmpty())
continue;
qDebug() << "Processing" << url;
// The isLocalFile() check below doesn't work as intended without an explicit scheme.
@ -1125,6 +1128,11 @@ void MainWindow::processURLs(QList<QUrl> urls)
auto localFileName = QDir::toNativeSeparators(local_url.toLocalFile());
QFileInfo localFileInfo(localFileName);
if (localFileName.isEmpty() || !localFileInfo.exists()) {
qDebug() << "Ignoring invalid path" << localFileName;
continue;
}
auto type = ResourceUtils::identify(localFileInfo);
if (ModPlatform::ResourceTypeUtils::VALID_RESOURCES.count(type) == 0) { // probably instance/modpack