Merge pull request #575 from Ryex/blockedmods-only-drop-local

Prevent potental crash if droping non local files in BlockedModsDialog
This commit is contained in:
Sefa Eyeoglu 2022-12-10 02:46:55 +01:00 committed by GitHub
commit 590875d022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,7 +84,15 @@ void BlockedModsDialog::dragEnterEvent(QDragEnterEvent* e)
void BlockedModsDialog::dropEvent(QDropEvent* e)
{
for (const QUrl& url : e->mimeData()->urls()) {
for (QUrl& url : e->mimeData()->urls()) {
if (url.scheme().isEmpty()) { // ensure isLocalFile() works correctly
url.setScheme("file");
}
if (!url.isLocalFile()) { // can't drop external files here.
continue;
}
QString filePath = url.toLocalFile();
qDebug() << "[Blocked Mods Dialog] Dropped file:" << filePath;
addHashTask(filePath);