mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +00:00
Migrate away from deprecated API
This commit is contained in:
parent
56c0f39593
commit
bf58555a7a
@ -142,8 +142,12 @@ namespace
|
|||||||
bool loadTorrentResumeData(const QByteArray &data, CreateTorrentParams &torrentParams, int &queuePos, MagnetUri &magnetUri)
|
bool loadTorrentResumeData(const QByteArray &data, CreateTorrentParams &torrentParams, int &queuePos, MagnetUri &magnetUri)
|
||||||
{
|
{
|
||||||
lt::error_code ec;
|
lt::error_code ec;
|
||||||
|
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||||
lt::bdecode_node root;
|
lt::bdecode_node root;
|
||||||
lt::bdecode(data.constData(), (data.constData() + data.size()), root, ec);
|
lt::bdecode(data.constData(), (data.constData() + data.size()), root, ec);
|
||||||
|
#else
|
||||||
|
const lt::bdecode_node root = lt::bdecode(data, ec);
|
||||||
|
#endif
|
||||||
if (ec || (root.type() != lt::bdecode_node::dict_t)) return false;
|
if (ec || (root.type() != lt::bdecode_node::dict_t)) return false;
|
||||||
|
|
||||||
torrentParams = CreateTorrentParams();
|
torrentParams = CreateTorrentParams();
|
||||||
|
@ -87,11 +87,16 @@ TorrentInfo TorrentInfo::load(const QByteArray &data, QString *error) noexcept
|
|||||||
// used in `torrent_info()` constructor
|
// used in `torrent_info()` constructor
|
||||||
const int depthLimit = 100;
|
const int depthLimit = 100;
|
||||||
const int tokenLimit = 10000000;
|
const int tokenLimit = 10000000;
|
||||||
lt::error_code ec;
|
|
||||||
|
|
||||||
|
lt::error_code ec;
|
||||||
|
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||||
lt::bdecode_node node;
|
lt::bdecode_node node;
|
||||||
bdecode(data.constData(), (data.constData() + data.size()), node, ec
|
bdecode(data.constData(), (data.constData() + data.size()), node, ec
|
||||||
, nullptr, depthLimit, tokenLimit);
|
, nullptr, depthLimit, tokenLimit);
|
||||||
|
#else
|
||||||
|
const lt::bdecode_node node = lt::bdecode(data, ec
|
||||||
|
, nullptr, depthLimit, tokenLimit);
|
||||||
|
#endif
|
||||||
if (ec) {
|
if (ec) {
|
||||||
if (error)
|
if (error)
|
||||||
*error = QString::fromStdString(ec.message());
|
*error = QString::fromStdString(ec.message());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user