Qt: MainWindow::dropEvent fixes.

Limit our dropped file count to 100. Make sure we always accept our
proposed action and either accept or ignore the event. Blind attempt at
fixing bug 14609.

Change-Id: Id08b179b6eb63529aa15bce7284460fbd19f7fec
Ping-Bug: 14609
Reviewed-on: https://code.wireshark.org/review/27462
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2018-05-11 12:46:49 -07:00
parent 4413d43962
commit f4724d0b37
1 changed files with 10 additions and 3 deletions

View File

@ -989,19 +989,26 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *event)
void MainWindow::dropEvent(QDropEvent *event)
{
QList<QByteArray> local_files;
int max_dropped_files = 100; // Arbitrary
foreach (QUrl drop_url, event->mimeData()->urls()) {
QString drop_file = drop_url.toLocalFile();
if (!drop_file.isEmpty()) {
local_files << drop_file.toUtf8();
if (local_files.size() >= max_dropped_files) {
break;
}
}
}
if (local_files.size() < 1) {
return;
}
event->acceptProposedAction();
if (local_files.size() < 1) {
event->ignore();
return;
}
event->accept();
if (local_files.size() == 1) {
openCaptureFile(local_files.at(0));