mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Delete LoadTorrentParams when load torrent failed
This commit is contained in:
parent
3faa7226e7
commit
124cc9621d
@ -4424,9 +4424,15 @@ void Session::dispatchTorrentAlert(const lt::alert *a)
|
|||||||
|
|
||||||
void Session::createTorrent(const lt::torrent_handle &nativeHandle)
|
void Session::createTorrent(const lt::torrent_handle &nativeHandle)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_loadingTorrents.contains(nativeHandle.info_hash()));
|
#if (LIBTORRENT_VERSION_NUM >= 20000)
|
||||||
|
const auto torrentID = TorrentID::fromInfoHash(nativeHandle.info_hashes());
|
||||||
|
#else
|
||||||
|
const auto torrentID = TorrentID::fromInfoHash(nativeHandle.info_hash());
|
||||||
|
#endif
|
||||||
|
|
||||||
const LoadTorrentParams params = m_loadingTorrents.take(nativeHandle.info_hash());
|
Q_ASSERT(m_loadingTorrents.contains(torrentID));
|
||||||
|
|
||||||
|
const LoadTorrentParams params = m_loadingTorrents.take(torrentID);
|
||||||
|
|
||||||
auto *const torrent = new TorrentImpl {this, m_nativeSession, nativeHandle, params};
|
auto *const torrent = new TorrentImpl {this, m_nativeSession, nativeHandle, params};
|
||||||
m_torrents.insert(torrent->id(), torrent);
|
m_torrents.insert(torrent->id(), torrent);
|
||||||
@ -4475,10 +4481,18 @@ void Session::handleAddTorrentAlert(const lt::add_torrent_alert *p)
|
|||||||
{
|
{
|
||||||
if (p->error)
|
if (p->error)
|
||||||
{
|
{
|
||||||
qDebug("/!\\ Error: Failed to add torrent!");
|
const QString msg = QString::fromStdString(p->message());
|
||||||
QString msg = QString::fromStdString(p->message());
|
LogMsg(tr("Couldn't load torrent. Reason: %1.").arg(msg), Log::WARNING);
|
||||||
LogMsg(tr("Couldn't load torrent. Reason: %1").arg(msg), Log::WARNING);
|
|
||||||
emit loadTorrentFailed(msg);
|
emit loadTorrentFailed(msg);
|
||||||
|
|
||||||
|
const lt::add_torrent_params ¶ms = p->params;
|
||||||
|
const bool hasMetadata = (params.ti && params.ti->is_valid());
|
||||||
|
#if (LIBTORRENT_VERSION_NUM >= 20000)
|
||||||
|
const auto id = TorrentID::fromInfoHash(hasMetadata ? params.ti->info_hashes() : params.info_hashes);
|
||||||
|
#else
|
||||||
|
const auto id = TorrentID::fromInfoHash(hasMetadata ? params.ti->info_hash() : params.info_hash);
|
||||||
|
#endif
|
||||||
|
m_loadingTorrents.remove(id);
|
||||||
}
|
}
|
||||||
else if (m_loadingTorrents.contains(p->handle.info_hash()))
|
else if (m_loadingTorrents.contains(p->handle.info_hash()))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user