Browse Source

Merge pull request #3234 from glassez/openfile

Fix crash when cancel open file dialog.
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
061fbeff56
  1. 24
      src/gui/mainwindow.cpp

24
src/gui/mainwindow.cpp

@ -1028,18 +1028,20 @@ void MainWindow::on_actionOpen_triggered()
QFileDialog::getOpenFileNames(0, tr("Open Torrent Files"), pref->getMainLastDir(), QFileDialog::getOpenFileNames(0, tr("Open Torrent Files"), pref->getMainLastDir(),
tr("Torrent Files") + QString::fromUtf8(" (*.torrent)")); tr("Torrent Files") + QString::fromUtf8(" (*.torrent)"));
const bool useTorrentAdditionDialog = Preferences::instance()->useAdditionDialog(); const bool useTorrentAdditionDialog = Preferences::instance()->useAdditionDialog();
foreach (QString file, pathsList) { if (!pathsList.isEmpty()) {
qDebug("Dropped file %s on download list", qPrintable(file)); foreach (QString file, pathsList) {
if (useTorrentAdditionDialog) qDebug("Dropped file %s on download list", qPrintable(file));
AddNewTorrentDialog::show(file, this); if (useTorrentAdditionDialog)
else AddNewTorrentDialog::show(file, this);
BitTorrent::Session::instance()->addTorrent(file); else
} BitTorrent::Session::instance()->addTorrent(file);
}
// Save last dir to remember it // Save last dir to remember it
QStringList top_dir = Utils::Fs::fromNativePath(pathsList.at(0)).split("/"); QStringList top_dir = Utils::Fs::fromNativePath(pathsList.at(0)).split("/");
top_dir.removeLast(); top_dir.removeLast();
pref->setMainLastDir(Utils::Fs::fromNativePath(top_dir.join("/"))); pref->setMainLastDir(Utils::Fs::fromNativePath(top_dir.join("/")));
}
} }
void MainWindow::activate() void MainWindow::activate()

Loading…
Cancel
Save