From 77b3a0c4cd7944589a22562eeabf7562dae70fd7 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Tue, 16 Jun 2015 09:08:25 +0300 Subject: [PATCH] Fix crash when cancel open file dialog. Closes #3232. --- src/gui/mainwindow.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index c2061e580..5c56a74da 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1028,18 +1028,20 @@ void MainWindow::on_actionOpen_triggered() QFileDialog::getOpenFileNames(0, tr("Open Torrent Files"), pref->getMainLastDir(), tr("Torrent Files") + QString::fromUtf8(" (*.torrent)")); const bool useTorrentAdditionDialog = Preferences::instance()->useAdditionDialog(); - foreach (QString file, pathsList) { - qDebug("Dropped file %s on download list", qPrintable(file)); - if (useTorrentAdditionDialog) - AddNewTorrentDialog::show(file, this); - else - BitTorrent::Session::instance()->addTorrent(file); - } + if (!pathsList.isEmpty()) { + foreach (QString file, pathsList) { + qDebug("Dropped file %s on download list", qPrintable(file)); + if (useTorrentAdditionDialog) + AddNewTorrentDialog::show(file, this); + else + BitTorrent::Session::instance()->addTorrent(file); + } - // Save last dir to remember it - QStringList top_dir = Utils::Fs::fromNativePath(pathsList.at(0)).split("/"); - top_dir.removeLast(); - pref->setMainLastDir(Utils::Fs::fromNativePath(top_dir.join("/"))); + // Save last dir to remember it + QStringList top_dir = Utils::Fs::fromNativePath(pathsList.at(0)).split("/"); + top_dir.removeLast(); + pref->setMainLastDir(Utils::Fs::fromNativePath(top_dir.join("/"))); + } } void MainWindow::activate()