mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
Merge pull request #7792 from Chocobo1/creator2
Fix crash when aborting a torrent creation process
This commit is contained in:
commit
a38730eb9e
2 changed files with 19 additions and 19 deletions
|
@ -35,8 +35,8 @@
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <libtorrent/bencode.hpp>
|
#include <libtorrent/bencode.hpp>
|
||||||
#include <libtorrent/create_torrent.hpp>
|
#include <libtorrent/create_torrent.hpp>
|
||||||
#include <libtorrent/torrent_info.hpp>
|
|
||||||
#include <libtorrent/storage.hpp>
|
#include <libtorrent/storage.hpp>
|
||||||
|
#include <libtorrent/torrent_info.hpp>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
@ -44,15 +44,18 @@
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
|
|
||||||
namespace libt = libtorrent;
|
namespace
|
||||||
using namespace BitTorrent;
|
{
|
||||||
|
|
||||||
// do not include files and folders whose
|
// do not include files and folders whose
|
||||||
// name starts with a .
|
// name starts with a .
|
||||||
bool fileFilter(const std::string &f)
|
bool fileFilter(const std::string &f)
|
||||||
{
|
{
|
||||||
return !Utils::Fs::fileName(QString::fromStdString(f)).startsWith('.');
|
return !Utils::Fs::fileName(QString::fromStdString(f)).startsWith('.');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace libt = libtorrent;
|
||||||
|
using namespace BitTorrent;
|
||||||
|
|
||||||
TorrentCreatorThread::TorrentCreatorThread(QObject *parent)
|
TorrentCreatorThread::TorrentCreatorThread(QObject *parent)
|
||||||
: QThread(parent)
|
: QThread(parent)
|
||||||
|
@ -64,7 +67,7 @@ TorrentCreatorThread::TorrentCreatorThread(QObject *parent)
|
||||||
TorrentCreatorThread::~TorrentCreatorThread()
|
TorrentCreatorThread::~TorrentCreatorThread()
|
||||||
{
|
{
|
||||||
requestInterruption();
|
requestInterruption();
|
||||||
wait(1000);
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentCreatorThread::create(const QString &inputPath, const QString &savePath, const QStringList &trackers,
|
void TorrentCreatorThread::create(const QString &inputPath, const QString &savePath, const QStringList &trackers,
|
||||||
|
|
|
@ -67,14 +67,14 @@ TorrentCreatorDlg::TorrentCreatorDlg(QWidget *parent, const QString &defaultPath
|
||||||
|
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Torrent"));
|
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Torrent"));
|
||||||
|
|
||||||
connect(m_ui->addFileButton, SIGNAL(clicked(bool)), SLOT(onAddFileButtonClicked()));
|
connect(m_ui->addFileButton, &QPushButton::clicked, this, &TorrentCreatorDlg::onAddFileButtonClicked);
|
||||||
connect(m_ui->addFolderButton, SIGNAL(clicked(bool)), SLOT(onAddFolderButtonClicked()));
|
connect(m_ui->addFolderButton, &QPushButton::clicked, this, &TorrentCreatorDlg::onAddFolderButtonClicked);
|
||||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(onCreateButtonClicked()));
|
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &TorrentCreatorDlg::onCreateButtonClicked);
|
||||||
connect(m_ui->buttonCalcTotalPieces, &QAbstractButton::clicked, this, &TorrentCreatorDlg::updatePiecesCount);
|
connect(m_ui->buttonCalcTotalPieces, &QPushButton::clicked, this, &TorrentCreatorDlg::updatePiecesCount);
|
||||||
|
|
||||||
connect(m_creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString)));
|
connect(m_creatorThread, &BitTorrent::TorrentCreatorThread::creationSuccess, this, &TorrentCreatorDlg::handleCreationSuccess);
|
||||||
connect(m_creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
|
connect(m_creatorThread, &BitTorrent::TorrentCreatorThread::creationFailure, this, &TorrentCreatorDlg::handleCreationFailure);
|
||||||
connect(m_creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int)));
|
connect(m_creatorThread, &BitTorrent::TorrentCreatorThread::updateProgress, this, &TorrentCreatorDlg::updateProgressBar);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
updateInputPath(defaultPath);
|
updateInputPath(defaultPath);
|
||||||
|
@ -86,9 +86,6 @@ TorrentCreatorDlg::~TorrentCreatorDlg()
|
||||||
{
|
{
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
||||||
if (m_creatorThread)
|
|
||||||
delete m_creatorThread;
|
|
||||||
|
|
||||||
delete m_ui;
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue