mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Work around crash when procesing recursive download
The messagebox is modal and exec() it makes it generates a new local event loop, however the new local event loop will continue to process libtorrent events (in Session::readAlerts()), at the time exec() returns, the original libt::alert pointers are lost and resume processing alerts will cause the crash. One solution is to make the messagebox use show() and avoid exec(). Closes #9086.
This commit is contained in:
parent
1a7021156e
commit
78d7cc0570
@ -927,18 +927,26 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHand
|
||||
{
|
||||
Preferences *const pref = Preferences::instance();
|
||||
if (pref->recursiveDownloadDisabled()) return;
|
||||
// Get Torrent name
|
||||
QString torrentName = torrent->name();
|
||||
QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent '%1' contains torrent files, do you want to proceed with their download?").arg(torrentName), QMessageBox::NoButton, this);
|
||||
QPushButton *yes = confirmBox.addButton(tr("Yes"), QMessageBox::YesRole);
|
||||
/*QPushButton *no = */ confirmBox.addButton(tr("No"), QMessageBox::NoRole);
|
||||
QPushButton *never = confirmBox.addButton(tr("Never"), QMessageBox::NoRole);
|
||||
confirmBox.exec();
|
||||
|
||||
if (confirmBox.clickedButton() == yes)
|
||||
BitTorrent::Session::instance()->recursiveTorrentDownload(torrent->hash());
|
||||
else if (confirmBox.clickedButton() == never)
|
||||
pref->disableRecursiveDownload();
|
||||
const auto torrentHash = torrent->hash();
|
||||
|
||||
QMessageBox *confirmBox = new QMessageBox(QMessageBox::Question, tr("Recursive download confirmation")
|
||||
, tr("The torrent '%1' contains torrent files, do you want to proceed with their download?").arg(torrent->name())
|
||||
, QMessageBox::NoButton, this);
|
||||
confirmBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
confirmBox->setModal(true);
|
||||
|
||||
const QPushButton *yes = confirmBox->addButton(tr("Yes"), QMessageBox::YesRole);
|
||||
/*QPushButton *no = */ confirmBox->addButton(tr("No"), QMessageBox::NoRole);
|
||||
const QPushButton *never = confirmBox->addButton(tr("Never"), QMessageBox::NoRole);
|
||||
connect(confirmBox, &QMessageBox::buttonClicked, this, [torrentHash, yes, never](const QAbstractButton *button)
|
||||
{
|
||||
if (button == yes)
|
||||
BitTorrent::Session::instance()->recursiveTorrentDownload(torrentHash);
|
||||
if (button == never)
|
||||
Preferences::instance()->disableRecursiveDownload();
|
||||
});
|
||||
confirmBox->show();
|
||||
}
|
||||
|
||||
void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const
|
||||
|
Loading…
x
Reference in New Issue
Block a user